Skip to content

Commit

Permalink
Merge branch 'prody:main' into interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
karolamik13 authored Dec 12, 2024
2 parents 53e916c + da5904d commit 7a3a11f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
43 changes: 36 additions & 7 deletions prody/database/dali.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")
Expand All @@ -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()):
Expand All @@ -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
4 changes: 2 additions & 2 deletions prody/dynamics/anmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions prody/tests/dynamics/test_anmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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,
Expand All @@ -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')

Expand Down

0 comments on commit 7a3a11f

Please sign in to comment.