From: Josh Vermaas (vermaas2_at_illinois.edu)
Date: Wed Feb 11 2015 - 18:30:25 CST

Hi Bharat,

Why are you doing it this way? Here is what I would do:

set bigsel [atomselect top "water and name OH2"] ;#I think thats the
name for a water oxygen.

#Loop over frames
for { set f 0 } { $f < [molinfo top get numframes] } { incr f } {
     $bigsel frame $f
     set cl [measure contacts 10 $bigsel] ; #Lookup what measure
contacts does. You probably want something to measure O-O distances that
aren't too far away, right? Note that this isn't PBC correct
     foreach i [lindex $cl 0] j [lindex $cl 1] {
         #Do measurements here. i and j will be the indices of your
water oxygens.
         puts "$i $j"
     }
}

This gives you a limited number of interesting water molecules at a time.

-Josh Vermaas

On 02/11/2015 12:14 PM, Bharat Sharma wrote:
> Hello,
> I am interested in getting index number from residue number. For
> example, I have a water molecule with residue # 63 which has three
> atoms O H H with indices 189 190 191. I am only interested to get O
> index, i.e. 189.
>
> e.g. puts $res gives 63. I want to use something like $res get
> (....???....) which gives index number. Since variable $res is a
> number, I am not sure how to get index unless it has some connection
> with indices.
>
> Is there any way to get first index? Actually I need this to get the
> bond between O-O. If there is a way to get O-O bond from residue, it's
> fine too. I do not want to select again atom and get indexes, because
> I have many loops where I need residue numbers not index numbers.
>
> Thank you.
>
> Bharat
>