Skip to content

Commit 7caefc3

Browse files
committed
update warnings and errors
1 parent 710f986 commit 7caefc3

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

test/test_align.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@ def setUp(self):
1010
self.pdb = 'pdb/1AK4/1AK4_10w.pdb'
1111

1212
def test_align(self):
13-
"""test the routine."""
13+
"""Test align()"""
1414

1515
for idir, axis in zip([0, 1, 2], ['x', 'y', 'z']):
16-
sql = align(self.pdb, axis=axis)
17-
xyz = np.array(sql.get('x,y,z'))
16+
with self.assertWarns(UserWarning) as ex:
17+
db = align(self.pdb, axis=axis)
18+
xyz = np.array(db.get('x,y,z'))
1819
u, v = pca(xyz)
1920
vmax = np.abs(v[:, np.argmax(u)])
2021
assert np.argmax(vmax) == idir
2122

2223
def test_align_interface(self):
23-
"""test the routine."""
24+
"""Test align_interface()"""
2425

25-
def get_xyz_interface(sql):
26-
idx = sql.get_contact_atoms()
26+
def get_xyz_interface(db):
27+
idx = db.get_contact_atoms()
2728
idx = idx['A'] + idx['B']
28-
return np.array(sql.get('x,y,z', rowID=idx))
29+
return np.array(db.get('x,y,z', rowID=idx))
2930

3031
for idir, plane in zip([2, 1, 0], ['xy', 'xz', 'yz']):
31-
sql = align_interface(self.pdb, plane=plane)
32-
xyz = get_xyz_interface(sql)
32+
with self.assertWarns(UserWarning) as ex:
33+
db = align_interface(self.pdb, plane=plane)
34+
xyz = get_xyz_interface(db)
3335
u, v = pca(xyz)
3436
vmax = np.abs(v[:, np.argmin(u)])
3537
assert np.argmax(vmax) == idir
3638

39+
if __name__ == '__main__':
40+
unittest.main()

test/test_superpose.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ class TestSuperpose(unittest.TestCase):
77
"""Test the superpose functionality"""
88

99
def setUp(self):
10-
1110
self.pdb1 = 'pdb/1AK4/1AK4_5w.pdb'
1211
self.pdb2 = 'pdb/1AK4/1AK4_10w.pdb'
1312

1413
def test_superpose(self):
15-
"""test the routine."""
16-
superpose(self.pdb1, self.pdb2, chainID='A')
14+
"""Test superpose()"""
15+
with self.assertWarns(UserWarning) as ex:
16+
superpose(self.pdb1, self.pdb2, chainID='A')
17+
18+
def test_superpose_backbone_error(self):
19+
"""Test superpose() backbone error when specifying `name`"""
20+
with self.assertWarns(UserWarning) as ex:
21+
with self.assertRaises(ValueError) as err:
22+
superpose(self.pdb1, self.pdb2, name='CA')
23+
err_msg = err.exception.args[0]
24+
target = "Atom type specified but only_backbone == True"
25+
self.assertIn(target, err_msg)
1726

18-
@unittest.expectedFailure
19-
def test_fails(self):
20-
superpose(self.pdb1, self.pdb2, name='CA')
27+
if __name__ == '__main__':
28+
unittest.main()

0 commit comments

Comments
 (0)