From: Sara baretller (sarabiocomputation_at_gmail.com)
Date: Wed Jul 06 2011 - 09:38:20 CDT

I have been having a problem with this script , I will really appreciate
your help. so the script does get me the angle between two vectors but then
it will not go to the next loop. it stops in the first. by giving the angle
between the first vector and the vector {0 1 0 }.

Script:

 for {set j 0} {$j < 6} {incr j} {

                set outfile [open "out.dat" "w"]

                set mol [molinfo top]

                set sel1 [atomselect $mol "residue $j and resname LEU and
name BBc"]

                set sel2 [atomselect $mol "residue $j and resname GLU and
name BBc"]

                $sel1 frame $j
                $sel2 frame $j

                $sel1 update
                $sel2 update

                puts "residue $j of 6 peptides"
                puts "$sel1 $sel2"

                set nLEU [llength [$sel1 list]]
                set nGLU [llength [$sel2 list]]

                set coord1 [$sel1 get { x y z }]
                set coord2 [$sel2 get { x y z }]

                set vec1 [vecsub [lindex $coord1 0] [lindex $coord2 0]]

                set vec2 {0 1 0}

                set vec1l [veclength $vec1]
                set vec2l [veclength $vec2]

                if {$vec1l != 0} {
                set vec1 [vecnorm $vec1]
                }
                if {$vec2l != 0} {
                set vec2 [vecnorm $vec2]
                }

                set dotprod [vecdot $vec1 $vec2]

                set angle [expr acos($dotprod)]

                set angle [expr ($angle * 180/3.14159)]
                puts "Final angle : $angle"
                puts $angle
                }

close $outfile

tcl councel:

angle 1.5284741404344042
Final angle : 87.57519131337723
87.57519131337723

Thank you

Sara