From: Josh Vermaas (vermaas2_at_illinois.edu)
Date: Mon May 05 2014 - 14:06:43 CDT

Hi Ramin,

You need to specify the frame of your atomselection/update your
atomselection:

set frames [molinfo top get numframes]

set fp [open "waters.txt" w]

set ligand "protein and resid 37"
set a [atomselect top "(water within 7 of ($ligand) and oxygen)"]

for {set i 0} {$i < $frames} {incr i} {
                puts "Frame: $i"
                #Something like this will change the frame number and
update the selection as appropriate.
                $a frame $i
                $a update
                set num [$a num]
                puts $fp "$i $num"
                $a delete
}

close $fp

Its in the docs.
-Josh

On 05/05/2014 01:05 PM, Ramin Ekhteiari wrote:
> Dear Norman,
> I employed this script but it did not change the frames the only it
> writes the frame No.
>
>
> Cheers,
> Ramin.
>
> set frames [molinfo top get numframes]
>
> set fp [open "waters.txt" w]
>
> set ligand "protein and resid 37"
>
>
>
> for {set i 0} {$i < $frames} {incr i} {
> puts "Frame: $i"
> set a [atomselect top "(water within 7 of ($ligand)
> and oxygen)"]
> set num [$a num]
> puts $fp "$i $num"
> $a delete
> }
>
> close $fp
> Out put is :
> 0 11
> 1 11
> 2 11
> 3 11
> 4 11
> 5 11
> 6 11
> 7 11
> 8 11
> 9 11
> 10 11
> 11 11
> 12 11
> 13 11
> 14 11
> 15 11
> 16 11
> 17 11
> 18 11
> 19 11
> 20 11
> 21 11
> 22 11
> 23 11
> 24 11
> 25 11
> 26 11
> 27 11
> 28 11
> 29 11
> 30 11
> .
> .
> .
>
> On , Ramin Ekhteiari <ramin_ekh_at_yahoo.com> wrote:
> Dear Norman,
> I employed this script but it did not change the frames the only it
> writes the frame No.
>
>
> Cheers,
> Ramin.
>
> set frames [molinfo top get numframes]
>
> set fp [open "waters.txt" w]
>
> set ligand "protein and resid 37"
>
>
>
> for {set i 0} {$i < $frames} {incr i} {
> puts "Frame: $i"
> set a [atomselect top "(water within 7 of ($ligand)
> and oxygen)"]
> set num [$a num]
> puts $fp "$i $num"
> $a delete
> }
>
> close $fp
> Out put is :
> 0 11
> 1 11
> 2 11
> 3 11
> 4 11
> 5 11
> 6 11
> 7 11
> 8 11
> 9 11
> 10 11
> 11 11
> 12 11
> 13 11
> 14 11
> 15 11
> 16 11
> 17 11
> 18 11
> 19 11
> 20 11
> 21 11
> 22 11
> 23 11
> 24 11
> 25 11
> 26 11
> 27 11
> 28 11
> 29 11
> 30 11
> .
> .
> .
>
> On Monday, May 5, 2014 2:52 PM, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:
> On Mon, May 5, 2014 at 4:47 AM, Ramin Ekhteiari
> <ramin_ekh_at_remove_yahoo.com <mailto:ramin_ekh_at_remove_yahoo.com>> wrote:
> > Hi dear all,
> >
> > I would like to calculate number of water molecules within 5
> angstroms of
> > the ligand
> > which is bonded to the protein for each step during MD.
> > I tried to do it for one step, but not for all as loop at TCL.
> >
> > So would you please advise me on how to do it.
>
> examples for how to do a loop over all trajectory frames are in the
> user's guide.
>
>
>
> >
> > Would be grateful for any advice.
> >
> >
> > Cheers,
> > Ramin.
>
>
>
>
> --
> Dr. Axel Kohlmeyer akohlmey_at_gmail.com <mailto:akohlmey_at_gmail.com>
> http://goo.gl/1wk0
> College of Science & Technology, Temple University, Philadelphia PA, USA
> International Centre for Theoretical Physics, Trieste. Italy.
>
>
>
>
>
>