Commit 58d0c548 authored by Rafal P. Wiewiora's avatar Rafal P. Wiewiora
Browse files

tests

parent 101c3cfa
...@@ -70,7 +70,6 @@ class TestPdbFile(unittest.TestCase): ...@@ -70,7 +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): def assertVecAlmostEqual(self, p1, p2, tol=1e-7):
unit = p1.unit unit = p1.unit
p1 = p1.value_in_unit(unit) p1 = p1.value_in_unit(unit)
...@@ -79,7 +78,21 @@ class TestPdbFile(unittest.TestCase): ...@@ -79,7 +78,21 @@ class TestPdbFile(unittest.TestCase):
for i in range(3): for i in range(3):
diff = abs(p1[i]-p2[i])/scale diff = abs(p1[i]-p2[i])/scale
self.assertTrue(diff < tol) self.assertTrue(diff < tol)
def test_ExtraParticles(self):
"""Test reading, and writing and re-reading of a file containing extra particle atoms."""
pdb = PDBFile('systems/tip5p.pdb')
for atom in pdb.topology.atoms():
if atom.index > 2:
self.assertEqual(None, atom.element)
output = StringIO()
PDBFile.writeFile(pdb.topology, pdb.positions, output)
input = StringIO(output.getvalue())
pdb = PDBFile(input, extraParticleIdentifier = '')
for atom in pdb.topology.atoms():
if atom.index > 2:
self.assertEqual(None, atom.element)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
CRYST1 30.000 30.000 30.000 90.00 90.00 90.00 P 1 1
ATOM 1 O HOH A 1 20.612 20.351 16.218 1.00 0.00 O
ATOM 2 H1 HOH A 1 20.565 20.405 15.264 1.00 0.00 H
ATOM 3 H2 HOH A 1 21.273 19.679 16.387 1.00 0.00 H
ATOM 4 D1 HOH A 1 20.808 20.964 16.492 1.00 0.00 EP
ATOM 5 D2 HOH A 1 19.994 20.162 16.486 1.00 0.00 EP
TER 6 HOH A 1
END
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