[BioPython] Torsional angle
Andrew Dalke
dalke at dalkescientific.com
Mon Sep 26 10:09:06 EDT 2005
Hi Omid,
> Could someone please help me with measuring a torsional angle given
> the PDB coordinates of the 4 atoms involved in it.
See the thread including
http://www.rcsb.org/pdb/lists/pdb-l/200409/001936.html
and more details in
http://www.math.fsu.edu/~quine/IntroMathBio_04/torsion_pdb/
torsion_pdb.pdf
There is Biopython code for computing a torsional angle.
>>> from Bio.PDB import Vector
>>> p1 = Vector.Vector( [0.0, 0.0, 1.0] )
>>> p2 = Vector.Vector( [0.0, 0.0, 0.0] )
>>> p3 = Vector.Vector( [0.0, 1.0, 0.0] )
>>> p4 = Vector.Vector( [1.0, 1.0, 0.0] )
>>> Vector.calc_dihedral(p1, p2, p3, p4)
1.5707963267948966
>>>
However, I think that's only in CVS. The code is
def calc_dihedral(v1, v2, v3, v4):
"""
Calculate the dihedral angle between 4 vectors
representing 4 connected points. The angle is in
]-pi, pi].
@param v1, v2, v3, v4: the four points that define the dihedral
angle
@type v1, v2, v3, v4: L{Vector}
"""
ab=v1-v2
cb=v3-v2
db=v4-v3
u=ab**cb
v=db**cb
w=u**v
angle=u.angle(v)
# Determine sign of angle
try:
if cb.angle(w)>0.001:
angle=-angle
except ZeroDivisionError:
# dihedral=pi
pass
return angle
This depends on a Bio.PDB-specific Vector class which
implements the "angle" method.
def angle(self, other):
"Return angle between two vectors"
n1=self.norm()
n2=other.norm()
c=(self*other)/(n1*n2)
# Take care of roundoff errors
c=min(c,1)
c=max(-1,c)
return arccos(c)
Andrew
dalke at dalkescientific.com
More information about the BioPython
mailing list