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

From: Grace Brannigan (
Date: Sat Oct 18 2008 - 23:05:45 CDT

Hi Stanley,

This is best addressed to the VMD list, not the NAMD list.

However, the problem with your script is that you do not have the "frame"
flag before "$i" - the correct syntax is

puts $outfile "[measure bond {6086 2421} frame $i]"

The $sel frame $i command does nothing because you are not passing that $sel
to the measure command. Also, if you just use the command

measure bond {index1 index2} frame all

it will return a list of the bond over all frames, so there is no need to
make an explicit loop the way you are doing. You can then just write that
list to a file.


On Sat, Oct 18, 2008 at 10:15 PM, wayj86 wayj86 <> wrote:

> Dear NAMD users,
> I was trying to calculate the distance between two atoms frame by frame
> with the VMD's function bond and the scripts below was something wrong:
> set outfile [open distance.dat
> w];
> set nf [molinfo top get numframes]
> set sel [atomselect top "protein"]
> # rmsd calculation loop
> for {set i 1 } {$i < $nf } { incr i } {
> $sel frame $i
> puts $outfile "[measure bond {6086 2421} $i]"
> }
> close $outfile
> With this script I can only get the distance of the present frame.So could
> you please tell me how should I modify my script?Thank you so much for any
> help.
> Best wishes,
> Stanley
> --
> The future is now!

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