From: Jan Saam (jan.saam_at_charite.de)
Date: Wed Jun 04 2003 - 11:37:41 CDT

Hi Thomas,
this script does the job.

Jan

# Computes the dihedral angle of a bond
# (takes the indices of the four dihedral atoms as input)
proc dihed_angle { a1 a2 a3 a4 {frame 0}} {
 set coord1 [lindex [[atomselect top "index $a1" frame $frame] get {x y z}] 0]
 set coord2 [lindex [[atomselect top "index $a2" frame $frame] get {x y z}] 0]
 set coord3 [lindex [[atomselect top "index $a3" frame $frame] get {x y z}] 0]
 set coord4 [lindex [[atomselect top "index $a4" frame $frame] get {x y z}] 0]
 set v1 [vecsub $coord1 $coord2]
 set v2 [vecsub $coord3 $coord2]
 set v3 [vecsub $coord4 $coord3]
 
 set cross1 [vecnorm [veccross $v2 $v1]]
 set cross2 [vecnorm [veccross $v2 $v3]]
 set dot [vecdot $cross1 $cross2]
 if {$dot>1.0 && $dot<1.0001} {set dot 1.0}
 if {$dot<-1.0 && $dot>-1.0001} {set dot -1.0}
 if {$dot>1.0 || $dot<-1.0} {
       puts "dihed_angle: dot>1.0, cannot compute acos($dot)"
 }
 set angle [rad2deg [expr acos($dot)]]
 return $angle

Am Mittwoch, 4. Juni 2003 17:58 schrieb Thomas Hedegaard Pedersen:
> Hi,
>
> Does anyone know if there is an easy way to obtain dihedral angles
> from within a tcl-script. I'm aware that for a protein it is easy to
> obtain the phi and psi angles by using the: get phi (or get psi),
> calls, but are there someway that the dihedral for a given selection
> of 4 atoms can be obtained (by a simple function call)????
>
> In addition, is it possible to rotate some parts of a molecule by
> specifying a new dihedral, as it is possible to use the move command
> to move atomselections by some given distance x, y, z????
>
> Thank you
>
> Stud. Polyt.
> Thomas Hedegaard Pedersen
> Department of Chemistry
> Technical University of Denmark