From: Justin Gullingsrud (justin_at_ks.uiuc.edu)
Date: Tue Mar 18 2003 - 16:52:12 CST

On Tue, Mar 18, 2003 at 02:28:34PM -0800, B. Bennion wrote:
> one more question how would I loop that of a number of frames and get the
> result to text file ?

Good question! Here's the wrong way and the right way, for illustration:

WRONG WAY:
set n [molinfo top get numframes]
for { set i 0 } { $i < $n } { incr i } {
  set sel [atomselect top "name OH2 ..." frame $i]
  lappend nwat [$sel num]
}

RIGHT WAY:
set n [molinfo top get numframes]
set sel [atomselect top "name OH2 ..."]
for { set i 0 } { $i < $n } { incr i } {
  $sel frame $i
  $sel update # recompute the waters that are in the distance range
  lappend nwat [$sel num]
}

The second way is better because the memory from the atom selections isn't
freed until the loop exits, which can run you out of physical memory if you
have a large trajectory.

Cheers,

Justin

>
> Brian
>
>
> On Tue, 18 Mar 2003, Justin Gullingsrud wrote:
>
> > Date: Tue, 18 Mar 2003 16:19:36 -0600
> > From: Justin Gullingsrud <justin_at_ks.uiuc.edu>
> > To: B. Bennion <bbennion_at_u.washington.edu>
> > Cc: vmd-l_at_ks.uiuc.edu
> > Subject: Re: atomselect
> >
> > Hi,
> >
> > On Tue, Mar 18, 2003 at 02:03:05PM -0800, B. Bennion wrote:
> > >
> > > Hi all,
> > >
> > > Is it possible to glean the number of residues that are found for a give
> > > atomselect command
> > >
> > > ie I want to know how many waters were found when I issue
> > > atomselect [water and same residue as (within 2.6 of protein)]
> > >
> > > Thanks for any help.
> > > Brian
> >
> > Two ways off the top of my head:
> > 1) Use "name OH2 and water and ...." so that you get one atom per water.
> > 2) llength [lsort -unique [$sel get residue]]
> >
> > Cheers,
> > Justin
> >
> > >
> > >
> > >
> > >
> > >
> > > Graduate Research Assistant
> > > Dep. Medicinal Chemistry, University of Washington
> > > Tel# (206)616-2779
> > > BOX 357610 Seattle WA 98195
> > >
> > > email--bbennion_at_u.washington.edu
> > > web page--http://students.washington.edu/bbennion
> >
> > --
> >
> > Justin Gullingsrud 3111 Beckman Institute 217-244-8946
> > I been dropping the new science, and I be kicking the new knowledge,
> > and I'm seeing to a degree that you can't get in college. -- b.boys
> >
>
>
>
>
> Graduate Research Assistant
> Dep. Medicinal Chemistry, University of Washington
> Tel# (206)616-2779
> BOX 357610 Seattle WA 98195
>
> email--bbennion_at_u.washington.edu
> web page--http://students.washington.edu/bbennion

-- 
  Justin Gullingsrud        3111 Beckman Institute        217-244-8946
  I been dropping the new science, and I be kicking the new knowledge,
  and I'm seeing to a degree that you can't get in college.  -- b.boys