From 66906b2027142ec9358da6cc5c790a61e046bafc Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 23 Oct 2024 13:00:31 +0100 Subject: [PATCH 1/6] getDihedral from multi coordsets --- prody/measure/measure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prody/measure/measure.py b/prody/measure/measure.py index 4d8678fd2..285e9a18a 100644 --- a/prody/measure/measure.py +++ b/prody/measure/measure.py @@ -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 @@ -207,12 +207,12 @@ 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 radian: return rad From d40131686c428ba399dfb8cdfaa11afb63d99d0f Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 23 Oct 2024 13:03:56 +0100 Subject: [PATCH 2/6] extract single --- prody/measure/measure.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prody/measure/measure.py b/prody/measure/measure.py index 285e9a18a..89e77114a 100644 --- a/prody/measure/measure.py +++ b/prody/measure/measure.py @@ -214,6 +214,10 @@ def getDihedral(coords1, coords2, coords3, coords4, radian=False): rad = arccos((v1*v2).sum(-1) / ((v1**2).sum(-1) * (v2**2).sum(-1))**0.5) if not all(porm == 0): rad = rad * porm + + if rad.shape[0] == 1: + rad = rad[0] + if radian: return rad else: From 93c30ed59358fff17c3cc763076c10e72c1f521b Mon Sep 17 00:00:00 2001 From: James Krieger Date: Sun, 1 Dec 2024 20:27:38 +0100 Subject: [PATCH 3/6] diversify if conditions for _parseMMCIFLines --- prody/proteins/ciffile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/proteins/ciffile.py b/prody/proteins/ciffile.py index 36cefdb4f..0abedf9fe 100644 --- a/prody/proteins/ciffile.py +++ b/prody/proteins/ciffile.py @@ -312,12 +312,12 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset, stop = 0 while not doneAtomBlock: line = lines[i] - if line[:11] == '_atom_site.': + if line.strip()[:11] == '_atom_site.': fieldCounter += 1 fields[line.split('.')[1].strip()] = fieldCounter foundAtomFields = True - elif foundAtomFields and line.strip() != '#': + elif foundAtomFields and line.strip() not in ['#', '']: if not foundAtomBlock: foundAtomBlock = True start = i From ec0eafa27e1ac23a7a0b1d583389536e195cefd4 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 3 Dec 2024 15:04:18 +0100 Subject: [PATCH 4/6] add get measure funcs --- prody/measure/measure.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prody/measure/measure.py b/prody/measure/measure.py index 89e77114a..29a19ee49 100644 --- a/prody/measure/measure.py +++ b/prody/measure/measure.py @@ -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', From 3b533ed77bcb52cf4b7006b5f0b1bbd4efc09a8b Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 3 Dec 2024 18:16:14 +0100 Subject: [PATCH 5/6] num_steps default to 5 --- prody/dynamics/anmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/dynamics/anmd.py b/prody/dynamics/anmd.py index a89a55ad0..7da0a0683 100755 --- a/prody/dynamics/anmd.py +++ b/prody/dynamics/anmd.py @@ -43,7 +43,7 @@ __all__ = ['runANMD'] -def runANMD(atoms, num_modes=2, max_rmsd=2., num_steps=2, tolerance=10.0, +def runANMD(atoms, num_modes=2, max_rmsd=2., num_steps=5, tolerance=10.0, **kwargs): """Runs the ANMD hybrid simulation method ([CM22]_), which generates conformations along single modes using :func:`.traverseModes` and minimises them. @@ -67,7 +67,7 @@ def runANMD(atoms, num_modes=2, max_rmsd=2., num_steps=2, tolerance=10.0, :type max_rmsd: float :arg num_steps: number of conformers in each direction for each mode - Default is 2 + Default is 5 :type num_steps: int :arg tolerance: tolerance for energy minimisation in OpenMM From b7426719ef3805a3e7acca643bba5ae1a70d4e53 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 3 Dec 2024 18:18:14 +0100 Subject: [PATCH 6/6] num_steps 2 in tests still --- prody/tests/dynamics/test_anmd.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prody/tests/dynamics/test_anmd.py b/prody/tests/dynamics/test_anmd.py index 25f499c96..f4ef9120c 100644 --- a/prody/tests/dynamics/test_anmd.py +++ b/prody/tests/dynamics/test_anmd.py @@ -32,12 +32,12 @@ def testAnmdAtomsWrongType(self): def testAnmdNumModesWrongType(self): """Test response to wrong type *num_modes* argument.""" if prody.PY3K: - self.assertRaises(TypeError, self.runANMD, self.ATOMS, 'nogood') + self.assertRaises(TypeError, self.runANMD, self.ATOMS, 'nogood', num_steps=2) def testAnmdRmsdWrongType(self): """Test response to wrong type *max_rmsd* argument.""" if prody.PY3K: - self.assertRaises(TypeError, self.runANMD, self.ATOMS, max_rmsd='nogood') + self.assertRaises(TypeError, self.runANMD, self.ATOMS, max_rmsd='nogood', num_steps=2) def testAnmdStepsWrongType(self): """Test response to wrong type *num_steps* argument.""" @@ -47,14 +47,14 @@ def testAnmdStepsWrongType(self): def testAnmdToleranceWrongType(self): """Test response to wrong type *tolerance* argument.""" if prody.PY3K: - self.assertRaises(TypeError, self.runANMD, self.ATOMS, tolerance='nogood') + self.assertRaises(TypeError, self.runANMD, self.ATOMS, tolerance='nogood', num_steps=2) class TestAnmdResults(TestANMD): def testResults(self): """Test results with default parameters""" if prody.PY3K: - DEFAULT_RESULTS = runANMD(self.ATOMS) + DEFAULT_RESULTS = runANMD(self.ATOMS, num_steps=2) ens1 = DEFAULT_RESULTS[0] assert_equal(len(DEFAULT_RESULTS), 2, @@ -70,7 +70,7 @@ def testResults(self): def testResultsNumModes1(self): """Test that num_modes=1 gives 1 ensemble""" if prody.PY3K: - RESULTS = runANMD(self.ATOMS, num_modes=1) + RESULTS = runANMD(self.ATOMS, num_modes=1, num_steps=2) assert_equal(len(RESULTS), 1, 'runANMD with num_modes=1 failed to give 1 ensemble')