VMD-L Mailing List
From: Tibbitt, Jeffrey A. (JTibbitt_at_odu.edu)
Date: Wed Oct 22 2008 - 11:56:30 CDT
- Next message: Axel Kohlmeyer: "RE: dcd format"
- Previous message: Leonardo Trabuco: "Re: A question about the plugin of salt bridge plugin"
- In reply to: JONATHAN BLACK: "dcd format"
- Next in thread: Axel Kohlmeyer: "RE: dcd format"
- Reply: Axel Kohlmeyer: "RE: dcd format"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Jonathan,
My FORTRAN code for reading an entire trajectory is different than what you have and may be easier to follow. It is very short and well commented. I'll explain it. The lines beginning with a c are comments. The first line is just a my name for the program. The second group of lines declare the variables. Here you notice the * in different places. It specifies the sizes of the data types read in (here character*4 means a word 4 characters in length). It works similarly for integers, but it signifies bytes (I think) when applied to real numbers. The third group of lines open up the trajectory file and start reading it from the beginning. Other information is stored at the beginning before the coordinates. The fourth group of lines loop through the frames and read the coordinates.
The first thing in a trajectory to read is a word (here I call it header), 4 characters in length, containing the characters: CORD or VELO. It should be one of these two only and defines the trajectory as containing coordinates or velocities.
The second thing in the trajectory coming right after that is a 20 dimensional array of integers (called control). This contains information (control(1)=number of frames, control(2)=number of previous dynamic steps, control(3)=skip frequency for writing frames, control(4)=number of dynamics steps).
The third thing read is an integer (called ntitle). This is the dimension of the 4th thing read. This dimension is the same as the number of title lines written out by the MD software.
The fourth thing read is an array of characters of dimension ntitle (the dimension previously read). This array is called title here.
The fifth thing read is an integer stating the number of atoms (called natom here).
The sixth thing read are the coordinates. First frame coordinates come first. But all the x-coordinates come first, then all the ys then all the zs. First, all the x coordinates for the first frame are read. It is read in at once as an array natom in length (here I call it xx(natom)). Next, all the y coordinates of the first frame are read (yy(natom)). Then all the z coordinates are read (zz(natom). Repeat reading the coordinates with the second frame.
I've gone on at length here, because I know it is invaluable to have your own code to get at the information in the DCD trajectory. And I've seen this question before. Note that this is used only for a simple DCD trajectory with no fixed atoms. They are a little different if they contain that sort of stuff. I am not an expert at DCD format, but I know that this format works for my trajectories. For fixed atoms and other stuff included someone else can help. But hopefully this helps you in constructing one in Perl for yourself.
Jeff Tibbitt
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
program readdcd
c TRAJECTORY VARIABLES
character*4 header
integer control(20)
integer i,j,ntitle,natom,nf
character*80 title(4)
real*4 xx(natom)
real*4 yy(natom)
real*4 zz(natom)
c OPEN TRAJECTORY FILE
open(unit=56,file="tmp.dcd",status='old',form='unformatted')
c READ IN HEADER AND CONTROL INFO
read(56) header,control
c READ IN THE TITLE LINES
read(56) ntitle,(title(j),j=1,ntitle)
c READ IN NUMBER OF ATOMS
read(56) natom
c LOOP OVER FRAMES
do i=1,nf
c READ IN COORDINATES
read(56) xx
read(56) yy
read(56) zz
enddo
end program
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
________________________________________
From: owner-vmd-l_at_ks.uiuc.edu [owner-vmd-l_at_ks.uiuc.edu] On Behalf Of JONATHAN BLACK [nihilique_at_hotmail.com]
Sent: Wednesday, October 22, 2008 5:30 AM
To: vmd-l_at_ks.uiuc.edu
Subject: vmd-l: dcd format
actually i have to write a perl script that can do that as part of a larger program. i've found a fortran script that can do that but it will take me a while to "decode" how it does what it does since i don't know fortran. however i would like to ask for the format with which a dcd is packed. i've found this :
#===DCD=FORMAT==============================================
#HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS
#CORD files step1 step zeroes (zero) timestep zeroes
#C*4 INT INT INT 5INT INT DOUBLE 9INT
# [CHARACTER*20]
#===========================================================
#NTITLE TITLE
#INT C*MAXTITL
#C*2 C*80
#===========================================================
#NATOM
#INT
#===========================================================
#X(I), I=1,NATOM (DOUBLE)
#Y(I), I=1,NATOM
#Z(I), I=1,NATOM
#===========================================================
as part of another script but i don't know if it's true and accurate, and even if it is, i can't understand some parts of it (eg : character*20 at 5th line). Any guidelines would be appreciated. Thank you...
----------------------------------------
> From: gillescche_at_gmail.com
> Subject: Re: vmd-l:
> Date: Tue, 21 Oct 2008 08:22:01 -0400
> To: nihilique_at_hotmail.com
>
> Since you want the information contained in the dcd file I would use
> catdcd to write out the coordinates of a certain frame in some format
> you can use such as pdb or xyz.
>
> You can find catdcd here:
>
> http://www.ks.uiuc.edu/Development/MDTools/catdcd/
>
> If you want to include the files in a script I know there are some
> fortran reads that are given on the mailing list.
>
> Best
> Chris
>
> On Oct 21, 2008, at 5:16 AM, JONATHAN BLACK wrote:
>
>>
>> hi guys. i am a biologist and i haven't been programming in perl
>> for a long time so my question may seem a little naive but i'm at a
>> total loss and any help would be appreciated. i need a perl script
>> to convert some binary files (.dcd if anyone knows what they are)
>> to ascii or just extract the ascii that they contain. i tried plain
>> read with no results. i searched the net and i only found this code :
>>
>> use warnings;
>> use strict;
>> @ARGV == 2 or die "usage: $0 in_filename out_filename\n";
>> # get first argument, i.e filename my $in_filename = shift;
>> print "You chose input \n";
>> my $out_filename = shift;
>> print "You chose output \n";
>> #set infile to binary mode open INFILE, '', $out_filename or die
>> "can't open $out_filename: $!";
>> # read 8 bytes at a time
>> $/ = \8;
>> while ( )
>> {
>> print OUTFILE join( ', ', map sprintf( '0x%04x', $_ ), unpack 'S*',
>> $_ + ), "\n";
>> }
>>
>> but when i run it it comes out with four columns of something
>> seeming like hexadecimal (0xe15d ...). The dcd files are about 700
>> mb so i can't upload it for you to see it, but i managed to cut the
>> first 80kb of it with hexedit and i upload it here: http://
>> www.gigasize.com/get.php?d=7qfs5f331bf Does anyone have any idea or
>> some plain guidelines because i really need get it done for my
>> work. Thanks anyway!
>> _________________________________________________________________
>> You live life beyond your PC. So now Windows goes beyond your PC.
>> http://clk.atdmt.com/MRT/go/115298556/direct/01/
>
_________________________________________________________________
You live life beyond your PC. So now Windows goes beyond your PC.
http://clk.atdmt.com/MRT/go/115298556/direct/01/
_________________________________________________________________
Stay organized with simple drag and drop from Windows Live Hotmail.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_102008
- Next message: Axel Kohlmeyer: "RE: dcd format"
- Previous message: Leonardo Trabuco: "Re: A question about the plugin of salt bridge plugin"
- In reply to: JONATHAN BLACK: "dcd format"
- Next in thread: Axel Kohlmeyer: "RE: dcd format"
- Reply: Axel Kohlmeyer: "RE: dcd format"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]