From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Thu Sep 20 2007 - 10:20:08 CDT

On Thu, 20 Sep 2007, INPE (Ingrid Viveka Pettersson) wrote:

IP> Dear All,

dear ingrid,
 
IP> I am a very new VMD user and I would appreciate any help. I have
IP> run a simulation and I would like to analyse distances between
IP> different selected atoms in a serie of different frames in the
IP> trajectory. I would like to have the output as a text file so that I
IP> can use any software to get a plot. I apologize if I have missed
IP> the information in the manual.

well, the manual gives only a minimal description of what you can do.
it may be more useful to go through some of the available scripting
tutorials and have a look at the script library. also having a look
into a tcl tutorial should be helpful to get the basics of file i/o.
( try: http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html )

the kind of analysis you want to do is very straightforward to do,
the following (untested!!) script fragments should help:

# read files and gather info
set mol [mol new "system.psf" type psf waitfor all]
mol addfile "traj.dcd" type dcd waitfor all
set nf [molinfo $mol get numframes]

# define selections for atom pairs to watch
set dist1 [atomselect $mol {index 15 45}]
set dist2 [atomselect $mol {index 23 24}]

# loop over frames and write data
set fp [open "output-dist.dat" w]

for {set i 0} {$i < $nf} {incr i} {

  $dist1 frame $i
  set d1 [$dist1 get {x y z}]
  $dist2 frame $i
  set d2 [$dist2 get {x y z}]

  puts $fp "$i [vecdist [lindex $d1 0] [lindex $d1 1]] [vecdist [lindex $d2 0] [lindex $d2 1]]"
}

close $fp

cheers,
   axel.

IP>
IP> Yours sincerely,
IP>
IP> Ingrid Pettersson
IP>
IP>
IP> ___________________________________
IP>
IP> Ingrid Pettersson
IP> Research Scientist
IP> Structure & Biophysical Chemistry
IP>
IP> Novo Nordisk A/S
IP> Novo Nordisk Park
IP> DK-2760 Måløv
IP> Denmark
IP> +45 4443 4506 (direct)
IP> +45 30754506 (mobile)
IP> inpe_at_novonordisk.com
IP>
IP> This e-mail (including any attachments) is intended for the addressee(s) stated above only and may contain confidential information protected by law. You are hereby notified that any unauthorized reading, disclosure, copying or distribution of this e-mail or use of information contained herein is strictly prohibited and may violate rights to proprietary information. If you are not an intended recipient, please return this e-mail to the sender and delete it immediately hereafter. Thank you.
IP>
IP>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.