Skip to content

Commit

Permalink
add info test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Oct 6, 2023
1 parent 72ce526 commit 02fd0e9
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 27 deletions.
9 changes: 8 additions & 1 deletion prody/tests/datafiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@
'file': 'pdb3enl.pdb',
'n_atoms': 7294,
'models': 1
},
},
'3enl_addH': {
'pdb': '3enl',
'file': 'addH_pdb3enl.pdb',
'n_atoms': 7641,
'models': 1,
'n_h': 3999
},
'3enl_mmtf': {
'pdb': '3ENL',
'file': 'mmtf3enl.mmtf',
Expand Down
105 changes: 79 additions & 26 deletions prody/tests/proteins/test_waterbridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,75 @@

LOGGER.verbosity = 'none'

PATH_1UBI = pathDatafile('1ubi')
SPLIT_PATH = os.path.split(PATH_1UBI)
PATH_PDB = pathDatafile('3enl_addH')
SPLIT_PATH = os.path.split(PATH_PDB)
TARGET_PATH = os.path.join(SPLIT_PATH[0], 'wb_cluster_' + SPLIT_PATH[1])

class TestWaterBridges(unittest.TestCase):

def setUp(self):
"""Parse the PDB file and run the core calculations."""
self.atoms = parseDatafile('1ubi_addH')
self.waterBridgesChain = calcWaterBridges(self.atoms)
self.waterBridgesClust = calcWaterBridges(self.atoms, method='cluster')
self.atoms = parsePDB(PATH_PDB)

if prody.PY3K:
self.waterBridgesChain = calcWaterBridges(self.atoms)
self.chainMultiWater = self.waterBridgesChain[37]

self.waterBridgesClust = calcWaterBridges(self.atoms, method='cluster')
self.clustMultiWater = self.waterBridgesClust[36]

self.waterBridgesClustInfo = calcWaterBridges(self.atoms, method='cluster',
output='info')
self.clustInfoMultiWater = self.waterBridgesClustInfo[36]

self.pro0 = self.clustMultiWater.proteins[0]
self.pro1 = self.clustMultiWater.proteins[1]
self.w0 = self.clustMultiWater.waters[0]
self.w1 = self.clustMultiWater.waters[1]

@dec.slow
def testSingleWaterBridgesChain(self):
if prody.PY3K:
self.assertIsInstance(self.waterBridgesChain, list,
'calcWaterBridges output should be a list')
'calcWaterBridges chain output should be a list')

self.assertEqual(len(self.waterBridgesChain), 7,
'calcWaterBridges chain list should have 7 items')
self.assertEqual(len(self.waterBridgesChain), 77,
'calcWaterBridges chain list should have 77 items')

chain0 = self.waterBridgesChain[1]
self.assertIsInstance(chain0, prody.proteins.waterbridges.AtomicOutput,

self.assertIsInstance(self.chainMultiWater, prody.proteins.waterbridges.AtomicOutput,
'calcWaterBridges output should contain AtomicOutput')

self.assertEqual(len(chain0.proteins), 2,
self.assertEqual(len(self.chainMultiWater.proteins), 2,
'water bridges chains should have 2 protein items')
self.assertIsInstance(chain0.proteins[0], Atom,
self.assertIsInstance(self.chainMultiWater.proteins[0], Atom,
'protein items in water bridges chains should be Atom')

self.assertEqual(len(chain0.waters), 1,
'water bridges chain should have 1 waters item')
self.assertIsInstance(chain0.waters[0], Atom,
self.assertEqual(len(self.chainMultiWater.waters), 2,
'water bridges chain should have 2 water items')
self.assertIsInstance(self.chainMultiWater.waters[0], Atom,
'waters items in water bridges chains should be Atom')

@dec.slow
def testSingleWaterBridgesCluster(self):
if prody.PY3K:
self.assertIsInstance(self.waterBridgesClust, list,
'calcWaterBridges output should be a list')
'calcWaterBridges clust output should be a list')

self.assertEqual(len(self.waterBridgesClust), 7,
'calcWaterBridges clust list should have 7 items')
self.assertEqual(len(self.waterBridgesClust), 74,
'calcWaterBridges clust list should have 74 items')

clust1 = self.waterBridgesClust[1]
self.assertIsInstance(clust1, prody.proteins.waterbridges.AtomicOutput,
self.assertIsInstance(self.clustMultiWater, prody.proteins.waterbridges.AtomicOutput,
'calcWaterBridges output should contain AtomicOutput')

self.assertEqual(len(clust1.proteins), 3,
'some water bridges clusters should have 3 protein items')
self.assertIsInstance(clust1.proteins[0], Atom,
self.assertEqual(len(self.clustMultiWater.proteins), 2,
'tested water bridges multi-water cluster should have 3 protein items')
self.assertIsInstance(self.clustMultiWater.proteins[0], Atom,
'protein items in water bridges clusters should be Atom')

self.assertEqual(len(clust1.waters), 1,
'water bridges cluster should have 1 waters item')
self.assertIsInstance(clust1.waters[0], Atom,
self.assertEqual(len(self.clustMultiWater.waters), 2,
'tested water bridges multi-water cluster should have 2 waters items')
self.assertIsInstance(self.clustMultiWater.waters[0], Atom,
'waters items in water bridges clusters should be Atom')

@dec.slow
Expand All @@ -89,3 +102,43 @@ def testSaveWaterBridges(self):
self.assertFalse(np.equal(self.atoms.water.numAtoms(), self.saved.water.numAtoms()),
'savePDBWaterBridges did not change the number of water atoms')

@dec.slow
def testSingleWaterBridgesOutputInfo(self):
if prody.PY3K:
self.assertIsInstance(self.waterBridgesClustInfo, list,
'calcWaterBridges clust info output should be a list')

self.assertEqual(len(self.waterBridgesClustInfo), 74,
'calcWaterBridges clust info list should have 74 items')

self.assertIsInstance(self.clustInfoMultiWater, list,
'tested water bridges multi-water cluster info output should contain lists')

self.assertEqual(len(self.clustInfoMultiWater), 9,
'tested water bridges multi-water cluster info should have 9 items')
self.assertIsInstance(self.clustInfoMultiWater[0], str,
'info items in water bridges clusters should be str')


self.assertEqual(self.clustInfoMultiWater[0], self.pro0.getResname() + str(self.pro0.getResnum()),
'item 0 from selected info should be resname + resnum of atom 0')
self.assertEqual(self.clustInfoMultiWater[1], self.pro0.getName() + '_' + str(self.pro0.getIndex()),
'item 1 from selected info should be name + _ + index of atom 0')
self.assertEqual(self.clustInfoMultiWater[2], self.pro0.getChid(),
'item 2 from selected info should be chid of atom 0')

self.assertEqual(self.clustInfoMultiWater[3], self.pro1.getResname() + str(self.pro1.getResnum()),
'item 3 from selected info should be resname + resnum of atom 1')
self.assertEqual(self.clustInfoMultiWater[4], self.pro1.getName() + '_' + str(self.pro1.getIndex()),
'item 4 from selected info should be name + _ + index of atom 1')
self.assertEqual(self.clustInfoMultiWater[5], self.pro1.getChid(),
'item 5 from selected info should be chid of atom 1')

self.assertEqual(self.clustInfoMultiWater[6], calcDistance(self.pro0, self.pro1),
'item 6 from selected info should be distance from protein atom 0 to protein atom 1')
self.assertEqual(self.clustInfoMultiWater[7], len(self.clustMultiWater.waters),
'item 7 from selected info should be number of waters in the cluster')
self.assertEqual(self.clustInfoMultiWater[8],
list(map(lambda w: f"{w.getChid()}_{w.getIndex()}", self.clustMultiWater.waters)),
'item 8 from selected info should be chid and index for 2 water atoms')

0 comments on commit 02fd0e9

Please sign in to comment.