From: Nels Thorsteinson (nthorst_at_bcgsc.ca)
Date: Thu Dec 07 2006 - 17:31:01 CST

hello,

I load a trajectory, then for each frame, I loop through each residue and call "measure hbonds" in order to get the hydrogen bonds for each residue. Everything works fine with these atom selections:

set selection1 [atomselect top "residue $res" frame 1]
set selection2 [atomselect top "protein and not residue $res" frame 1]

where $res is the current residue number.

The problem is that these selections return way too many hydrogen bonds because all atoms are considered. So then I tried limiting the atoms to O N and S.

set selection1 [atomselect top {residue $res and (name "N.*" "O.*" "S.*")} frame $i]
set selection2 [atomselect top {protein and not residue $res and (name "N.*" "O.*" "S.*")} frame $i]

These selections are fine in and of themselves but when I use them in a loop over the residues, I witness some bug-like behavior. The atom selections do not get updated when the residue number $res is updated in the loop. The hydrogen bonds returned are always those from having $res=0 even when $res=56,57 etc. as I loop through the residues.

Here is the code:

        set res_list [atomselect top "all and name CA"]
        set resi [lsort -unique -integer [$res_list get residue]]
        $res_list delete
        
           for {set i $start_frame} {$i < $end_frame} {incr i 1} {

            set energy 0.0
                
            foreach res $resi {

                    set selection1 [atomselect top {residue $res and (name "N.*" "O.*" "S.*")} frame $i]
                    set selection2 [atomselect top {protein and not residue $res and (name "N.*" "O.*" "S.*")} frame $i]
                    set hbonds [measure hbonds 4.5 45 $selection1 $selection2 ]
                    $selection1 delete
                   $selection2 delete
               
                    if {$i==$start_frame} {
                    puts "residue $res"
                    puts "$hbonds"
                }
            }
        }

The puts "$hbonds" is always the same even though $res is always being updated

Thanks in advance for any help,
Nels

----------------------------------------------------------------------------
Nels Thorsteinson, UBC Bioinformatics
Graduate Student
CIHR Bioinformatics Training Program for Health Research
----------------------------------------------------------------------------