From: nordgren_at_sas.upenn.edu
Date: Sat May 07 2005 - 23:48:24 CDT

Axel, thank you so much -- that did the trick!

It hadn't occurred to me that the "animate" command would be so useful
in an analysis script, but indeed that was the tool I was missing.

Just to summarize, for those who may refer to this in the future, here
is the algorithm for using VMD to generate a DCD trajectory consisting
of a series of modified coordinate frames:

# load the structure and original set of coordinates
mol load psf $start_psf pdb $start_pdb
set whole [atomselect top all]
set frame 0
(loop begins here)
   # add new frame to the trajectory, with coords copied from previous frame
   animate dup frame $frame 0
   incr frame
   animate goto $frame
   # modify coords of new frame
   (do your own thing here)
}
# write the complete trajectory to disk
animate write dcd $final_dcd beg 0 end $frame waitfor all

- Erik

C. Erik Nordgren, Ph.D.
Department of Chemistry
University of Pennsylvania

Quoting Axel Kohlmeyer <axel.kohlmeyer_at_theochem.ruhr-uni-bochum.de>:

>
> On Fri, 6 May 2005 nordgren_at_sas.upenn.edu wrote:
>
> EN> Hello all,
>
> hello erik,
>
> EN> I would like to generate a series of coordinate frames using VMD
> EN> (based upon manipulations of a single reference configuration) and
> EN> then analyze the relative potential energies of the various
> EN> configurations (using NAMD).
>
> EN> I think the latter part of this will be simple (just do a loop inside
> NAMD
> EN> to read one frame at a time from a DCD file and "run 0" to compute the
> EN> energies), but the first part, to my surprise, has proven tricky.
>
> please have a look at the animate command. that contains the
> parts, that you are missing.
>
> EN> Here is what I tried:
> EN> --------
> EN> mol load psf $start_psf pdb $start_pdb
> EN> set whole [atomselect top all]
>
> EN> set frame 0
> EN> for {set z $start_z} {$z >= $final_z} {set z [expr $z - $delta]} {
>
> here you could insert:
>
> animate dup frame 0
> incr frame
> animate goto $frame
>
>
> EN> (modify my coordinates)
>
> the following is not needed:
>
> EN> molinfo top set frame $frame
> EN> # $whole frame $frame
> EN> $whole writedcd $final_dcd
> EN> incr frame
> EN> }
>
> and now you could do
>
> animate write dcd $final_dcd beg 0 end $frame waitfor all
>
> and after that you can exit. this is straight from the manual
> without testing, but that should at least give you another idea.
>
> best regards,
> axel.
>
> EN> This script runs, but the resulting DCD file contains only one frame.
> EN>
> EN> If I un-comment the "$whole frame $frame" line, then the script aborts
> EN> on its second trip through the loop; I get an error of:
> EN> atomsel: frame 1 out of range for molecule 0
> EN> So I guess my idea of setting the frame number in order to append it
> EN> to my DCD output file doesn't work either.
> EN>
> EN> I re-read the VMD manual for the "writeXXX" command (subset of the
> EN> "atomselect" command) but there's no detail about how to append frames
> EN> one at a time.
> EN>
> EN> I'm sure there's an easier way to do this... can anyone help?
> EN>
> EN> thanks much,
> EN> Erik
> EN>
> EN> C. Erik Nordgren, Ph.D.
> EN> Department of Chemistry
> EN> University of Pennsylvania
> EN>
> EN>
>
> --
>
> =======================================================================
> Dr. Axel Kohlmeyer e-mail: axel.kohlmeyer_at_theochem.ruhr-uni-bochum.de
> Lehrstuhl fuer Theoretische Chemie Phone: ++49 (0)234/32-26673
> Ruhr-Universitaet Bochum - NC 03/53 Fax: ++49 (0)234/32-14045
> D-44780 Bochum http://www.theochem.ruhr-uni-bochum.de/~axel.kohlmeyer/
> =======================================================================
> If you make something idiot-proof, the universe creates a better idiot.
>