From: McGuire, Kelly (mcg05004_at_byui.edu)
Date: Sun Feb 24 2019 - 21:47:16 CST

I have this script that calculates the distance between two groups of atoms for each frame. For some reason, the script
doesn't got through all of the frames. In this case, I have 1000 frames, and the script stops calculating distance at frame 915. Here is my script:

#This calculates the distance between the center-of-mass of two groups of atoms

#Selection for the two atoms of choice
 set A [atomselect top "resname ASN and resid 31"]
 set B [atomselect top "resname DEG"]

 #Get number of frames loaded into top molecule
 set numframes [molinfo top get numframes]

 #Open file for writing output
 set output [open "Distance.dat" w]

 #Write a short header to the file
 puts $output "Frame\tDistance"

 #Loop over all frames
 for {set i 0} {$i < $numframes} {incr i} {

 #Advance to frame i
 animate goto $i

 #Get the positions, find the vector from B to A, calculate the length of vector
 set distance [veclength [vecsub [measure center $A weight mass] [measure center $B weight mass] ] ]

 #Write the frame number and distance to file, separated by a tabulator
 puts $output "$i\t$distance"
 }

 #Close and clean up everything
 $A delete
 $B delete
 unset numframes
 unset output

Kelly L. McGuire

PhD Candidate

Biophysics

Department of Physiology and Developmental Biology

Brigham Young University

LSB 3050

Provo, UT 84602