From: maria goranovic (mariagoranovic_at_gmail.com)
Date: Mon Jul 11 2011 - 04:12:11 CDT

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?

2. I also cannot really understand the need of following lines of your
script?

# if there is information in the dipdate ($frame) list element

if {[info exists dipdata($frame)]} then {

# if $dipgraph has some value

if {[info exists dipgraph]} then {

# delete all elements of $dipgraph? Why?

foreach g $dipgraph {
graphics $molid delete $g
}
}

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?

########################
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?

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