From: Josh Vermaas (
Date: Mon Apr 06 2015 - 15:49:34 CDT

Hi Aryan,
You'll need a:

$sel update

after changing the frame number. You have a within call in your
atomselection, which will change per frame, but VMD wasn't told to
recalculate which atoms do/do not belong to the selection (most of the
time it doesn't change per frame, and its faster that way), so you get
the list of residues that was selected initially, which was from the
last frame.


On 04/06/2015 01:34 PM, Aryan Vahedi wrote:
> Hi John,
> Very nice to be talking to the lead developer of VMD! To answer your
> question, my intention is to use a script to identify residues that
> fall within the specified range and then conduct further analysis on
> them. I have created the following script but suspect there is an
> issue with it (numbers in red are specific to my loaded trajectory).
> >set sel [atomselect top "protein and within 3 of resname CNT"]
> >set completelist {}
> >for {set framenumber 0} {$framenumber < 1656} {incr framenumber} {
> >$sel frame $framenumber
> >set list1 [$sel get resid]
> >set completelist [concat $completelist $list1]
> }
> After sourcing the script, I use the following to pull up the residues:
> >lsort -unique $completelist
> And this gives me a list of residues. My issue is that this list
> matches the same exact residues that would come up if I just did the
> $sel get resid commandin the Tkconsole after skipping to the last
> frame in the trajectory I have loaded. As a result, I suspect that I
> am not properly using the loop (for) command properly. Indeed it seems
> like there are many more residues involved in the interaction over the
> entire course of the trajectory when I use the appropriate
> visualization and same selection (including update selection for each
> frame) under Graphical Representations.
> Am I correct, is the for loop command not being properly used in this
> case?
> Best,
> Aryan
> Morgan State University