Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Oct 30, 2024
1 parent 0fffa17 commit 32b1f3d
Showing 1 changed file with 55 additions and 50 deletions.
105 changes: 55 additions & 50 deletions prody/tests/dynamics/test_anmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,89 +14,94 @@

DATA = DATA_FILES['anmd']
ENSEMBLE = PDBEnsemble(parseDatafile('anmd'))
ENSEMBLE.setCoords(ENSEMBLE.getCoordsets()[2])

class TestANMD(unittest.TestCase):

def setUp(self):

from prody import runANMD
self.runANMD = runANMD
self.ATOMS = parseDatafile('1ubi')
if prody.PY3K:
from prody import runANMD
self.runANMD = runANMD
self.ATOMS = parseDatafile('1ubi')

def testAnmdAtomsWrongType(self):
"""Test response to wrong type *atoms* argument."""

self.assertRaises(TypeError, self.runANMD, 'nogood')
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, 'nogood')

def testAnmdNumModesWrongType(self):
"""Test response to wrong type *num_modes* argument."""

self.assertRaises(TypeError, self.runANMD, self.ATOMS, 'nogood')
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, self.ATOMS, 'nogood')

def testAnmdRmsdWrongType(self):
"""Test response to wrong type *max_rmsd* argument."""

self.assertRaises(TypeError, self.runANMD, self.ATOMS, max_rmsd='nogood')
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, self.ATOMS, max_rmsd='nogood')

def testAnmdStepsWrongType(self):
"""Test response to wrong type *num_steps* argument."""

self.assertRaises(TypeError, self.runANMD, self.ATOMS, num_steps='nogood')
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, self.ATOMS, num_steps='nogood')

def testAnmdToleranceWrongType(self):
"""Test response to wrong type *tolerance* argument."""

self.assertRaises(TypeError, self.runANMD, self.ATOMS, tolerance='nogood')
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, self.ATOMS, tolerance='nogood')

def testAnmdSolventWrongType(self):
"""Test response to wrong type *solvent* argument."""

self.assertRaises(TypeError, self.runANMD, self.ATOMS, solvent=1)
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, self.ATOMS, solvent=1)

def testAnmdSolventWrongValue(self):
"""Test response to wrong value *solvent* argument."""

self.assertRaises(ValueError, self.runANMD, self.ATOMS, solvent='nogood')
if prody.PY3K:
self.assertRaises(ValueError, self.runANMD, self.ATOMS, solvent='nogood')

def testAnmdFFWrongType(self):
"""Test response to wrong type *force_field* argument."""

self.assertRaises(TypeError, self.runANMD, self.ATOMS, force_field=1)
if prody.PY3K:
self.assertRaises(TypeError, self.runANMD, self.ATOMS, force_field=1)

def testAnmdFFWrongValue(self):
"""Test response to wrong value *force_field* argument."""

self.assertRaises(ValueError, self.runANMD, self.ATOMS, force_field='nogood')
if prody.PY3K:
self.assertRaises(ValueError, self.runANMD, self.ATOMS, force_field='nogood')

class TestAnmdResults(TestANMD):

def testResults(self):
DEFAULT_RESULTS = runANMD(self.ATOMS)
ens1 = DEFAULT_RESULTS[0]

assert_equal(len(DEFAULT_RESULTS), 2,
'runANMD with default parameters failed to give 2 ensembles')
assert_equal(len(ens1), DATA['models'],
'runANMD with default parameters failed to give ensembles with 5 conformers')

ens1.setCoords(ens1.getCoordsets()[2])
assert_allclose(ens1.getRMSDs(), ENSEMBLE.getRMSDs(),
rtol=1e-10, atol=0.1, # may not be so
err_msg='runANMD with default parameters failed to give expected RMSDs')

def testNumModes3(self):
RESULTS = runANMD(self.ATOMS, num_modes=1)
assert_equal(len(RESULTS), 1,
'runANMD with num_modes=1 failed to give 1 ensemble')

ens1 = RESULTS[0]
assert_equal(len(ens1), DATA['models'],
'runANMD with num_modes=1 failed to give ensembles with 5 conformers')

ens1.setCoords(ens1.getCoordsets()[2])
assert_allclose(ens1.getRMSDs(), ENSEMBLE.getRMSDs(),
rtol=1e-10, atol=0.1, # may not be so
err_msg='runANMD with num_modes=1 failed to give expected RMSDs')

if __name__ == '__main__' and prody.PY3K:
"""Test results with default parameters"""
if prody.PY3K:
DEFAULT_RESULTS = runANMD(self.ATOMS)
ens1 = DEFAULT_RESULTS[0]

assert_equal(len(DEFAULT_RESULTS), 2,
'runANMD with default parameters failed to give 2 ensembles')
assert_equal(len(ens1), DATA['models'],
'runANMD with default parameters failed to give ensembles with 5 conformers')

ens1.setCoords(ens1.getCoordsets()[2])
assert_allclose(ens1.getRMSDs(), ENSEMBLE.getRMSDs(),
rtol=1e-10, atol=0.1, # may not be so
err_msg='runANMD with default parameters failed to give expected RMSDs')

def testResultsNumModes1(self):
"""Test that num_modes=1 gives 1 ensemble"""
if prody.PY3K:
RESULTS = runANMD(self.ATOMS, num_modes=1)
assert_equal(len(RESULTS), 1,
'runANMD with num_modes=1 failed to give 1 ensemble')

ens1 = RESULTS[0]
assert_equal(len(ens1), DATA['models'],
'runANMD with num_modes=1 failed to give ensembles with 5 conformers')

ens1.setCoords(ens1.getCoordsets()[2])
assert_allclose(ens1.getRMSDs(), ENSEMBLE.getRMSDs(),
rtol=1e-10, atol=0.1, # may not be so
err_msg='runANMD with num_modes=1 failed to give expected RMSDs')

if __name__ == '__main__':
unittest.main()

0 comments on commit 32b1f3d

Please sign in to comment.