From: Justin Gullingsrud (justinrocks_at_gmail.com)
Date: Wed Jan 12 2005 - 11:08:15 CST

This is a recurring theme... In almost every case that I've seen,
especially those that involve looping over frames, it's almost _never_
necessary to create or delete atom selections in a loop over frames.
Instead, create the selections you need at the beginning, then use
"$sel frame $i" to change the frame of selection $sel to frame $i, and
use "$sel update" after that to have a selection recompute its atoms
for the new frame, if the selection is based on time-varying data like
coordinates.

For example, if you wanted to compute the RMSD between CA atoms in all frames:

set n [molinfo top get numframes]
set ref [atomselect top "name CA"]
set sel [atomselect top "name CA"]
for { set i 0 } { $i < $n } { incr i } {
  $ref frame $i
  for { set j $i } { $j < $n } { incr j } {
    $sel frame $j
    set rms($i,$j) [measure rmsds $sel $ref]
  }
}
  
The resulting script is usually simpler than if selections are created
and deleted inside the inner loop of the script.

Cheers,
Justin

On Wed, 12 Jan 2005 09:56:43 -0500, pbrenne1_at_nd.edu <pbrenne1_at_nd.edu> wrote:
>
> I was using VMD to calculate the O(number of dcds)^2 RMSD values that I need to
> implement a clustering algorithm and noticed that it is very important to
> specifically delete atomselect selections in .tcl scripts. The example script
> on page 36 of the tutorial might want to include a "$sel delete" line. I
> noticed this when the results of some batch jobs with a large number of dcds
> terminated early. They were overflowing a machine with 2GB of memory...
>
> Just a comment that I thought would be beneficial in the archive.
>
> Paul Brenner
>
>

-- 
The spirit of Plato dies hard.  We have been unable to escape the
philosophical tradition that what we can see and measure in the world
is merely the superficial and imperfect representation of an
underlying reality.
                -- S.J. Gould, "The Mismeasure of Man"