From: John Stone (johns_at_ks.uiuc.edu)
Date: Mon Jul 21 2008 - 23:50:56 CDT

Hi,
  When you load your trajectory, you should be adding
the "waitfor all" option to your load commands:
  mol new foo.dcd waitfor all

This will prevent VMD from continuing with your script
until the entire file has been loaded. The problems you
describe below are caused by running your script while file
loading is still in progress.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Tue, Jul 22, 2008 at 11:19:01AM +1000, David Poger wrote:
> Hello
>
> I wrote a Tcl script to do a really basic thing: loading a trajectory
> and taking a snapshot of each frame. However, it doesn't work. It seems
> the number of frames isn't correct. There are excatly 740 frames (and my
> file is not corrupted) and VMD invariably finds 4 frames (but, if after
> the trajectory is loaded, VMD finds the correct number of frames if I
> type 'molinfo top get numframes' in the VMD console window).
> Also, if I run VMD interactively (by typing 'vmd -e myscript.tcl'), the
> first 4 frames are effectively rendered but if I run VMD in batch ('vmd
> -dispdev text -e myscript.tcl'), the 4 files corresponding to the
> rendering are created but they are empty...
>
> Could anyone help me, please?
>
> Thanks,
>
> David
>
>
>
> Here is the script that I use:
>
> #################
> # command: vmd -dispdev text -e myscript.tcl
>
> # Axes off
> axes location off
> display antialias on
> display projection Orthographic
>
> # Load the gro file
> mol new firstframe.gro
> mol delrep 0 top
>
> # water: blue lines
> mol selection water
> mol representation Lines
> mol color ColorID 22
> mol addrep 0
> # other: white licorice
> mol selection {not water}
> # Licorice a n m, a=bond radius, n,m=sphere/bond resolutions
> mol representation Licorice 0.2 50 50
> mol color ColorID 8
> mol addrep 0
> # P: yellow vdw
> mol selection {name P}
> mol representation VDW 1.0 50
> mol color ColorID 4
> mol addrep 0
>
> # Periodic images
> mol showperiodic top 0 xzX
> mol numperiodic top 0 3
> mol showperiodic top 1 xzX
> mol numperiodic top 1 3
> mol showperiodic top 2 xzX
> mol numperiodic top 2 3
>
> # Center
> rotate x by 90
> scale by 1.5
> translate by 1 1.4 0
>
> display resize 834 834
>
> # Load the trajectory
> animate style once
> mol addfile ./XTC/trajectory.xtc top
>
> set nframes [molinfo top get numframes]
>
> set frame 0
>
> # Loop over the trajectory
> for {set i 0} {$i < $nframes} {incr i } {
> # go to the given frame
> animate goto $i
> # force display update
> display update
> puts "frame $i of $nframes"
> # filename
> set filename ./MOVIE/anim_[format "%04d" $frame].ppm
> # take the picture
> render snapshot $filename
>
> incr frame
> }
>
> exit
>
>
> --
>
> _________________________________________________
> David POGER, Ph.D.
> Postdoctoral Research Fellow
> Molecular Dynamics Group
> School of Molecular and Microbial Sciences (SMMS)
> Chemistry Building (#68)
> The University of Queensland
> Brisbane, QLD 4067
> Australia
>
> Email: d.poger_at_uq.edu.au
> Tel: +61 7 3365 7562
> Fax: +61 7 3365 3872
>
>
> ** Notice: Unless stated otherwise, this e-mail represents only the views
> of the Sender and not the views of The University of Queensland.

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078