From: Bryan Roessler (roessler_at_uab.edu)
Date: Thu Apr 19 2012 - 13:17:39 CDT

proc residue_hydration {firstFrame lastFrame} {
for {set f $firstFrame} {$f < $lastFrame} {incr $f} {
set sel1 [atomselect top "protein and within 3 of water"]
 $sel1 frame $f
lappend restotal [lsort -unique -integer [$sel1 get resid]]
 }
set outDataFile [open hydration.csv a]
for {set r 1} {$r < 1480} {incr r} {
 set num [llength [lsearch -exact -all $restotal $r]]
puts $outDataFile "$r,$num"
 unset indnumber num
}
close $outDataFile
}

I'm having a trouble with this hydration analysis script. I'm trying to
record the number of frames that a particular residue is within 3A of water.

Whenever I run the first for loop, it continues to infinity (crashing VMD)
although I cannot understand why. I've tried using "animate goto $f" and
"display update ui" to no avail. Note the use of the "-unique" switch so
that the residue is only counted once (even if multiple atoms are within 3A
of water).

It's driving me nuts!