From 3b533ed77bcb52cf4b7006b5f0b1bbd4efc09a8b Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 3 Dec 2024 18:16:14 +0100 Subject: [PATCH 1/3] 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 2/3] 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') From 913954bf86e54c2882c807d2d6c24c07376e4705 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Sun, 8 Dec 2024 13:16:06 +0100 Subject: [PATCH 3/3] add reverse to filterDaliMultimers --- prody/database/dali.py | 43 +++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/prody/database/dali.py b/prody/database/dali.py index 6f7c73b2f..a36976fd4 100644 --- a/prody/database/dali.py +++ b/prody/database/dali.py @@ -515,7 +515,7 @@ def getTitle(self): return self._title -def daliFilterMultimer(atoms, dali_rec, n_chains=None): +def daliFilterMultimer(atoms, dali_rec, n_chains=None, reverse=False): """ Filters multimers to only include chains with Dali mappings. @@ -524,6 +524,14 @@ def daliFilterMultimer(atoms, dali_rec, n_chains=None): :arg dali_rec: the DaliRecord object with which to filter chains :type dali_rec: :class:`.DaliRecord` + + :arg n_chains: the number of chains in multimers to keep + Default is None, keeping all multimers + :arg n_chains: int + + :arg reverse: whether to reverse filtering to exclude by n_chain + Default is False + :type reverse: bool """ if not isinstance(atoms, Atomic): raise TypeError("atoms should be an Atomic object") @@ -535,6 +543,12 @@ def daliFilterMultimer(atoms, dali_rec, n_chains=None): except: raise AttributeError("Dali Record does not have any data yet. Please run fetch.") + if not isinstance(n_chains, (int, type(None))): + raise TypeError('n_chains should be None or an integer') + + if not isinstance(reverse, bool): + raise TypeError('reverse should be a Boolean') + numChains = 0 atommap = None for i, chain in enumerate(atoms.iterChains()): @@ -546,17 +560,32 @@ def daliFilterMultimer(atoms, dali_rec, n_chains=None): else: atommap += chain - if n_chains is None or numChains == n_chains: - return atommap - else: - return None + if n_chains is None or \ + not reverse and numChains == n_chains or \ + reverse and numChains != n_chains: + return atommap + return None -def daliFilterMultimers(structures, dali_rec, n_chains=None): +def daliFilterMultimers(structures, dali_rec, n_chains=None, reverse=False): """A wrapper for daliFilterMultimer to apply to multiple structures. + + :arg structures: a list of :class:`.Atomic` objects to be filtered + :type structures: list + + :arg dali_rec: the DaliRecord object with which to filter chains + :type dali_rec: :class:`.DaliRecord` + + :arg n_chains: the number of chains in multimers to keep + Default is None, keeping all multimers + :arg n_chains: int + + :arg reverse: whether to reverse filtering to exclude by n_chain + Default is False + :type reverse: bool """ dali_ags = [] for entry in structures: - result = daliFilterMultimer(entry, dali_rec, n_chains) + result = daliFilterMultimer(entry, dali_rec, n_chains, reverse) if result is not None: dali_ags.append(result) return dali_ags