Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend getDihedral to work on many coordinate sets #2009

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions prody/measure/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from numpy import ndarray, power, sqrt, array, zeros, arccos, dot
from numpy import sign, tile, concatenate, pi, cross, subtract, var
from numpy import unique, where
from numpy import unique, where, divide, power

from prody.atomic import Atomic, Residue, Atom, extendAtomicData
from prody.kdtree import KDTree
Expand All @@ -16,11 +16,11 @@
if PY2K:
range = xrange

__all__ = ['buildDistMatrix', 'calcDistance',
'calcCenter', 'calcGyradius', 'calcAngle',
'calcDihedral', 'calcOmega', 'calcPhi', 'calcPsi',
'calcMSF', 'calcRMSF',
'calcDeformVector',
__all__ = ['buildDistMatrix', 'calcDistance', 'calcGyradius',
'calcCenter', 'calcAngle', 'calcDihedral',
'getCenter', 'getAngle', 'getDihedral',
'calcOmega', 'calcPhi', 'calcPsi',
'calcMSF', 'calcRMSF', 'calcDeformVector',
'buildADPMatrix', 'calcADPAxes', 'calcADPs',
'pickCentral', 'pickCentralAtom', 'pickCentralConf', 'getWeights',
'calcInertiaTensor', 'calcPrincAxes', 'calcDistanceMatrix',
Expand Down Expand Up @@ -207,13 +207,17 @@ def getDihedral(coords1, coords2, coords3, coords4, radian=False):
a3 = coords4 - coords3

v1 = cross(a1, a2)
v1 = v1 / (v1 * v1).sum(-1)**0.5
v1 = divide(v1, power((v1 * v1).sum(-1), 0.5).reshape(-1,1))
v2 = cross(a2, a3)
v2 = v2 / (v2 * v2).sum(-1)**0.5
v2 = divide(v2, power((v2 * v2).sum(-1), 0.5).reshape(-1,1))
porm = sign((v1 * a3).sum(-1))
rad = arccos((v1*v2).sum(-1) / ((v1**2).sum(-1) * (v2**2).sum(-1))**0.5)
if not porm == 0:
if not all(porm == 0):
rad = rad * porm

if rad.shape[0] == 1:
rad = rad[0]

if radian:
return rad
else:
Expand Down
Loading