Commit 7f802839 authored by Jason Swails's avatar Jason Swails
Browse files

Fix up Residue assignment in CharmmPsfFile Topology

Also fixes the test case.  Everything should pass now.
parent 84691dc4
...@@ -612,13 +612,13 @@ class CharmmPsfFile(object): ...@@ -612,13 +612,13 @@ class CharmmPsfFile(object):
last_residue = None last_residue = None
# Add each chain (separate 'system's) and residue # Add each chain (separate 'system's) and residue
for atom in self.atom_list: for atom in self.atom_list:
resid = '%d%s' % (atom.residue.idx, atom.residue.inscode)
if atom.system != last_chain: if atom.system != last_chain:
chain = topology.addChain(atom.system) chain = topology.addChain(atom.system)
last_chain = atom.system last_chain = atom.system
if atom.residue.idx != last_residue: if resid != last_residue:
last_residue = atom.residue.idx last_residue = resid
residue = topology.addResidue(atom.residue.resname, chain, residue = topology.addResidue(atom.residue.resname, chain, resid)
str(atom.residue.idx))
if atom.type is not None: if atom.type is not None:
# This is the most reliable way of determining the element # This is the most reliable way of determining the element
atomic_num = atom.type.atomic_number atomic_num = atom.type.atomic_number
......
...@@ -120,7 +120,7 @@ class TestCharmmFiles(unittest.TestCase): ...@@ -120,7 +120,7 @@ class TestCharmmFiles(unittest.TestCase):
psf = CharmmPsfFile('systems/4TVP-dmj_wat-ion.psf') psf = CharmmPsfFile('systems/4TVP-dmj_wat-ion.psf')
self.assertEqual(len(list(psf.topology.atoms())), 66264) self.assertEqual(len(list(psf.topology.atoms())), 66264)
self.assertEqual(len(list(psf.topology.residues())), 20169) self.assertEqual(len(list(psf.topology.residues())), 20169)
self.assertEqual(len(list(psf.bonds())), 46634) self.assertEqual(len(list(psf.topology.bonds())), 46634)
def test_ImplicitSolventForces(self): def test_ImplicitSolventForces(self):
"""Compute forces for different implicit solvent types, and compare them to ones generated with a previous version of OpenMM to ensure they haven't changed.""" """Compute forces for different implicit solvent types, and compare them to ones generated with a previous version of OpenMM to ensure they haven't changed."""
......
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