From: Axel Kohlmeyer (
Date: Fri Aug 10 2012 - 03:13:23 CDT

On Fri, Aug 10, 2012 at 9:23 AM, <> wrote:
> Hello everybody,
> I need some help for dcd files.
> Looking at the mailing list I found another guy that had a
> similar problem to mine. I need to export the coordinate
> of a dcd file in a simple "x y z" file (ascii).
> Using the email found here I was able to write this simple
> code:
> set file [open output.dat w]
> set rings [atomselect 0 "all"]
> set nfram [molinfo 0 get numframes]
> set natoms [$rings num]
> put $file "Num_of_atoms $natoms"
> put $file "Num_of_frames $nfram"
> for {set j 0} {$j < $nfram } { incr j } {
> $rings frame $j
> $rings update
> set coords [$rings get {x y z} ]
> put $file "$coords"
> }
> close $file

o dear. far too much effort.

> It simply put in a file all the coordinate of all the atoms
> in all the frames.
> To be more clear, imagine that you have 2 atoms and 2
> frames, you will get:
> {val_x_of_frame_1 val_y_of_frame_1
> val_z_of_frame_1}{val_x_of_frame_1
> val_x_of_frame_1val_x_of_frame_1 } {val_x_of_frame_2
> val_y_of_frame_2 val_z_of_frame_2}{val_x_of_frame_2
> val_y_of_frame_2 val_z_of_frame_2}
> The problem now is the following:
> do the coordinate, that I write for each frame, correspond
> to the same atom? I mean, in the first position (second and
> so on)
> do the coordinate refer to the same atom of the previous
> frame?

yes. provided this is how the dcd file was written.
VMD has no knowledge what the software that wrote
the dcd file did, but in general, atom coordinates are
written to dcd files in order and that order does not change.
at least this is how it is done in CHARMM, where the
dcd format originates from and other software follows this.

> Can somebody help please?
> Does somebody know a better way to export the dcd files to a
> text coordinate file?

why not just write it out as a xmol .xyz style file.
the molfile plugin library supports quite a few text based
file formats.

you can also use the command line tool catdcd to
do these conversions as it uses the molfile plugins
for file i/o.


> Thanks in advance

Dr. Axel Kohlmeyer
International Centre for Theoretical Physics, Trieste. Italy.