From: maria goranovic (mariagoranovic_at_gmail.com)
Date: Tue Jul 12 2011 - 14:19:51 CDT

Hi John

Thank you for the answers. I understand most of it.

I am trying to source in a file containing a new set of draw directives on
each frame, hence source alone does not work, which is why I was trying to
understand Axel's script.

It is still not clear to me what function (equivalent of do_dipframe) I
should call to "attach" the file to each frame ?

On Tue, Jul 12, 2011 at 8:19 PM, John Stone <johns_at_ks.uiuc.edu> wrote:

> Hi,
> I'll give you a few more tips on the questions you had below:
>
> On Mon, Jul 11, 2011 at 11:12:11AM +0200, maria goranovic wrote:
> > Hi Axel,
> > Thank you for the help. Appreciate it. I have 4 questions, if you do
> not
> > mind?
> > 1. In your example, you use the procedure do_dipdraw to execute a
> command
> > (vmd_draw_vector). In my case, I just need to read in the contents of
> a
> > file. So the procedure do_dipdraw should be replaced by a function
> which
> > reads in the entire file containing the draw commands. How do I do
> this?
>
> I haven't been following this thread so I'm not entirely sure what you're
> trying to do, but if you have a file that contains a bunch of drawing
> commands,
> you can simply execute the file like this:
> source filename.tcl
> or
> play filename.tcl
>
> The "source" command processes all of the commands in the file at once.
> The "play" command reads the file a line-at-a-time, and processes the
> commands on each line, causing display updates etc after each command.
> Generally it is best to use "source" unless you have a specific reason
> to use "play" instead.
>
> > 2. I also cannot really understand the need of following lines of your
> > script?*
>
> I added comments below.
>
> > # if there is information in the dipdate ($frame) list element
> > if {[info exists dipdata($frame)]} then {
>
> This line checks to see if the Tcl array contains data for the active
> frame...
>
> > # if $dipgraph has some value
> > if {[info exists dipgraph]} then {
>
> This line is checking to see if there is a "dipgraph" variable or not.
>
> > # delete all elements of $dipgraph? Why?
> > foreach g $dipgraph {
> > graphics $molid delete $g
> > }
>
> I assume this is deleting all of the old graphics objects, so that
> they can be redrawn on the next frame, without leaving the old objects
> from the previous frame displayed on the screen.
>
> > }
>
>
> > 3. I tried something like this, but run into problems. VMD seems
> unable to
> > exit from the for loop where the files are read and assigned to a
> variable
> > $lines($frame). Why does this happen? Am I not reading the file
> correctly?
>
> I believe your loop is not incrementing "i", but instead it is trying
> to increment "$i", which is most likely the source of your problem.
> You can save yourself a lot of trouble when debugging problems like this
> by adding a "puts" call within the loop and printing out the loop
> iteration, and/or any other information that is useful to determine
> what is happening in your code.
>
> > ########################
> > mol load gro protein.gro
> > mol addfile {protein.xtc} type {xtc} first 0 last 5 step 1 waitfor all
> > #proc readdata {} {
> > #What goes here??
> > #}
> > # read in files to be appended to each frame
> > set n [molinfo 0 get numframes]
> > # I think this is what you meant by : "you can just do a per frame
> > open/close and read in the file" ?
> > for {set i 0} {$i<$n} {incr $i} {
> > set dat [open "outputhole_$i.vmd_plot" r]
> > set lines($i) *[gets $dat]
> > close $dat
> > }
> > puts $lines(0)
> > ########################
> > 4. Each file that I am trying to read for each frame has about 27000
> draw
> > directives. I have about 100 frames. So can VMD easily handle
> 100*27000
> > lines in an array variable without choking on memory?*
>
> VMD has no particular limits, it is only a question of the machine you're
> using and whether you're running a 32-bit or 64-bit version of VMD.
>
> Cheers,
> John Stone
> vmd_at_ks.uiuc.edu
>
> > Thank you for the help
> > Maria
> > On Fri, Jul 8, 2011 at 6:20 PM, Axel Kohlmeyer <akohlmey_at_gmail.com>
> wrote:
> >
> > On Fri, Jul 8, 2011 at 10:56 AM, maria goranovic
> > <mariagoranovic_at_gmail.com> wrote:
> > > Hi Axel
> > > Thank you for the help. However, I am not much of an expert in tcl
> or
> > vmd
> > > scripting and am learning. Hopefully I can please get some help?
> >
> > i can try.
> > > One difference between your setup and mine seems to be that in
> your
> > setup
> > > all the data over frames which you are trying to import is lying
> in
> > one
> > > file, and you read the file one at a time?
> >
> > i read the data up front and store it away in an array that is
> indexed
> > by the frame number, since that is faster.
> > for the example of a dipole, there is not much data to store.
> > > So, here: each line is being read from zundel.dip and assigned to
> the
> > > dipdata($i) array.
> >
> > exactly.
> > > for {set i 0} {$i < $n} {incr i} {
> > > # advance selection to the current frame and update.
> > > $sel frame $n
> > > $sel update
> > > set dipdata($i) [list [center_of_mass $sel] [gets $dip]]
> > > }
> > > close $dip
> >
> > > However, the data I need to read in each frame is not one line,
> but an
> > > entire file.
> >
> > that doesn't make a difference. you can just do a per frame
> > open/close and read in the file. however, you can also stick
> > to the reading a file. the latter is just taking more time.
> > > Secondly, I did not really understand what seems to be the key
> > command:
> > > trace variable vmd_frame(0) w do_dipdraw
> >
> > > This means that the command do_dipdraw will be executed if
> > vmd_frame(0) is
> > > executed? what is the w for? what is vmd_frame(0) ?
> >
> > not executed but written to. vmd_frame is an array that records the
> > current frame number of each molecule. thus $vmd_frame(0) will give
> > you the current frame number for molecule 0. this array/variable
> will
> > be updated by VMD whenever a new frame becomes current, and
> > then the "trace" will be triggered and do_dipdraw is launched.
> >
> > HTH,
> > * axel.
> >
> > > Thank you again,
> > > Maria
> > > On Fri, Jul 8, 2011 at 3:31 PM, Axel Kohlmeyer <
> akohlmey_at_gmail.com>
> > wrote:
> > >>
> > >> On Fri, Jul 8, 2011 at 8:59 AM, maria goranovic
> > >> <mariagoranovic_at_gmail.com> wrote:
> > >> > Hi
> > >> > I have a trajectory, and I want to source in a different
> > draw-command
> > >> > containing file on each frame. The files to be sourced in
> contain
> > >> > several
> > >> > draw commands as below:
> > >> > ...
> > >> > draw point { * 67.340 * 84.391 * 32.398}
> > >> > draw point { * 67.340 * 84.391 * 32.340}
> > >> > draw point { * 67.340 * 84.410 * 32.284}
> > >> > draw point { * 67.340 * 84.446 * 32.238}
> > >> > draw point { * 67.340 * 84.495 * 32.206}
> > >> > draw point { * 67.340 * 84.552 * 32.192}
> > >> > draw point { * 67.340 * 84.611 * 32.196}
> > >> > draw point { * 67.340 * 84.664 * 32.220}
> > >> > draw point { * 67.340 * 84.707 * 32.260}
> > >> > draw point { * 67.340 * 84.735 * 32.311}
> > >> > draw point { * 67.353 * 84.567 * 32.605}
> > >> > ...
> > >> >
> > >> > the idea is to view the trajectory and draw a new set of points
> > each
> > >> > frame.
> > >> > Can someone please suggest how to accomplish this?
> > >> > I tried something like the following to load 5 frames from a
> > 125-frame
> > >> > trajectory. The files temp_$j.vmd_plot contain data like the
> above.
> > The
> > >> > script below works, except that only the last set of points
> i.e.
> > >> > outputhole_5.vmd_plot are displayed, and no others. When I look
> > back
> > >> > into
> > >> > the trajectory, VMD has lost information of previous
> > temp_$j.vmd_plot
> > >> > files.
> > >> > How do I keep the data in the display?
> > >>
> > >> that is not how this will work.
> > >>
> > >> have a look at item 5.2 in this document.
> > >>
> > >>
> > >>
> >
> http://sites.google.com/site/akohlmey/redirect/cpmd-vmd.pdf?attredirects=0&d=1
> > >>
> > >> cheers,
> > >> * *axel.
> > >>
> > >>
> > >> > ====================
> > >> > mol load gro protein-aligned-50ns.gro
> > >> > # Load trajectory
> > >> > for {set j 0} {$j < 5 } {incr j} {
> > >> > # i goes like 1, 26, 51 ...
> > >> > set i [expr ($j*25)+1]
> > >> > # k goes like 25, 50, 75 ...
> > >> > set k [expr ($j+1)*25]
> > >> > mol addfile {protein-aligned.xtc} type {xtc} first $i last $k
> step
> > 25
> > >> > waitfor 1 0
> > >> > # this file contains the draw statements
> > >> > source temp_$j.vmd_plot
> > >> > }
> > >> > ========================
> > >> >
> > >> > --
> > >> > Maria G.
> > >> > Technical University of Denmark
> > >> > Copenhagen
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Dr. Axel Kohlmeyer
> > >> akohlmey_at_gmail.com *http://goo.gl/1wk0
> > >>
> > >> Institute for Computational Molecular Science
> > >> Temple University, Philadelphia PA, USA.
> > >
> > >
> > >
> > > --
> > > Maria G.
> > > Technical University of Denmark
> > > Copenhagen
> > >
> >
> > --
> > Dr. Axel Kohlmeyer
> > akohlmey_at_gmail.com *http://goo.gl/1wk0
> >
> > Institute for Computational Molecular Science
> > Temple University, Philadelphia PA, USA.
> >
> > --
> > Maria G.
> > Technical University of Denmark
> > Copenhagen
>
> --
> NIH Resource for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> http://www.ks.uiuc.edu/~johns/ Phone: 217-244-3349
> http://www.ks.uiuc.edu/Research/vmd/ Fax: 217-244-6078
>

-- 
Maria G.
Technical University of Denmark
Copenhagen