Re: How can I calculate the distance between two atoms frame by frame?

From: Axel Kohlmeyer (
Date: Sat Oct 18 2008 - 22:07:13 CDT

On Sun, 19 Oct 2008, wayj86 wayj86 wrote:

SW> Dear NAMD users,

dear stanley,
SW> I was trying to calculate the distance between two atoms frame by frame with
SW> the VMD's function bond and the scripts below was something wrong:

if you have a question about VMD, why do you post it
to the NAMD mailing list and not to the VMD mailing list?

SW> set outfile [open distance.dat
SW> w];
SW> set nf [molinfo top get numframes]
SW> set sel [atomselect top "protein"]
SW> # rmsd calculation loop
SW> for {set i 1 } {$i < $nf } { incr i } {

SW> $sel frame $i

this statement has no effect, since
you don't use the selection below.

SW> puts $outfile "[measure bond {6086 2421} $i]"
SW> }
SW> close $outfile
SW> With this script I can only get the distance of the present frame.So could
SW> you please tell me how should I modify my script?Thank you so much for any

please have a closer look at the documentation of "measure bond".
you have an option "frame" and that does the obvious thing. just
putting $i there does not work...

but it will also generate the whole list right away.

set bl [measure bond {6086 2421} frame all]


SW> help.
SW> Best wishes,
SW> Stanley

Axel Kohlmeyer
   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.

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:49:59 CST