Commit 197eac74 authored by Rafal P. Wiewiora's avatar Rafal P. Wiewiora
Browse files

rearrange TestPdbFile.py

parent 58d0c548
...@@ -70,15 +70,6 @@ class TestPdbFile(unittest.TestCase): ...@@ -70,15 +70,6 @@ class TestPdbFile(unittest.TestCase):
pdb = PDBFile(open('systems/triclinic.pdb', 'rb')) pdb = PDBFile(open('systems/triclinic.pdb', 'rb'))
self.assertEqual(len(pdb.positions), 8) self.assertEqual(len(pdb.positions), 8)
def assertVecAlmostEqual(self, p1, p2, tol=1e-7):
unit = p1.unit
p1 = p1.value_in_unit(unit)
p2 = p2.value_in_unit(unit)
scale = max(1.0, norm(p1),)
for i in range(3):
diff = abs(p1[i]-p2[i])/scale
self.assertTrue(diff < tol)
def test_ExtraParticles(self): def test_ExtraParticles(self):
"""Test reading, and writing and re-reading of a file containing extra particle atoms.""" """Test reading, and writing and re-reading of a file containing extra particle atoms."""
pdb = PDBFile('systems/tip5p.pdb') pdb = PDBFile('systems/tip5p.pdb')
...@@ -91,8 +82,18 @@ class TestPdbFile(unittest.TestCase): ...@@ -91,8 +82,18 @@ class TestPdbFile(unittest.TestCase):
pdb = PDBFile(input, extraParticleIdentifier = '') pdb = PDBFile(input, extraParticleIdentifier = '')
for atom in pdb.topology.atoms(): for atom in pdb.topology.atoms():
if atom.index > 2: if atom.index > 2:
self.assertEqual(None, atom.element) self.assertEqual(None, atom.element)
def assertVecAlmostEqual(self, p1, p2, tol=1e-7):
unit = p1.unit
p1 = p1.value_in_unit(unit)
p2 = p2.value_in_unit(unit)
scale = max(1.0, norm(p1),)
for i in range(3):
diff = abs(p1[i]-p2[i])/scale
self.assertTrue(diff < tol)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment