Commit 7f4143a1 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1896 from peastman/patch

Ignore duplicate patch specifications
parents 546ec2fd fd948b0d
...@@ -426,8 +426,8 @@ class ForceField(object): ...@@ -426,8 +426,8 @@ class ForceField(object):
def registerTemplatePatch(self, residue, patch, patchResidueIndex): def registerTemplatePatch(self, residue, patch, patchResidueIndex):
"""Register that a particular patch can be used with a particular residue.""" """Register that a particular patch can be used with a particular residue."""
if residue not in self._templatePatches: if residue not in self._templatePatches:
self._templatePatches[residue] = [] self._templatePatches[residue] = set()
self._templatePatches[residue].append((patch, patchResidueIndex)) self._templatePatches[residue].add((patch, patchResidueIndex))
def registerScript(self, script): def registerScript(self, script):
"""Register a new script to be executed after building the System.""" """Register a new script to be executed after building the System."""
......
...@@ -67,8 +67,9 @@ class TestPatches(unittest.TestCase): ...@@ -67,8 +67,9 @@ class TestPatches(unittest.TestCase):
self.assertEqual(0, patch.addedExternalBonds[0].residue) self.assertEqual(0, patch.addedExternalBonds[0].residue)
self.assertEqual('C', patch.deletedExternalBonds[0].name) self.assertEqual('C', patch.deletedExternalBonds[0].name)
self.assertEqual(0, patch.deletedExternalBonds[0].residue) self.assertEqual(0, patch.deletedExternalBonds[0].residue)
self.assertEqual('Test', ff._templatePatches['RES'][0][0]) patch = list(ff._templatePatches['RES'])[0]
self.assertEqual(0, ff._templatePatches['RES'][0][1]) self.assertEqual('Test', patch[0])
self.assertEqual(0, patch[1])
def testParseMultiresiduePatch(self): def testParseMultiresiduePatch(self):
"""Test parsing a <Patch> tag that affects two residues.""" """Test parsing a <Patch> tag that affects two residues."""
...@@ -110,10 +111,12 @@ class TestPatches(unittest.TestCase): ...@@ -110,10 +111,12 @@ class TestPatches(unittest.TestCase):
self.assertEqual(0, patch.addedBonds[0][0].residue) self.assertEqual(0, patch.addedBonds[0][0].residue)
self.assertEqual('B', patch.addedBonds[0][1].name) self.assertEqual('B', patch.addedBonds[0][1].name)
self.assertEqual(1, patch.addedBonds[0][1].residue) self.assertEqual(1, patch.addedBonds[0][1].residue)
self.assertEqual('Test', ff._templatePatches['RESA'][0][0]) patchA = list(ff._templatePatches['RESA'])[0]
self.assertEqual(0, ff._templatePatches['RESA'][0][1]) self.assertEqual('Test', patchA[0])
self.assertEqual('Test', ff._templatePatches['RESB'][0][0]) self.assertEqual(0, patchA[1])
self.assertEqual(1, ff._templatePatches['RESB'][0][1]) patchB = list(ff._templatePatches['RESB'])[0]
self.assertEqual('Test', patchB[0])
self.assertEqual(1, patchB[1])
def testApplyPatch(self): def testApplyPatch(self):
"""Test applying a patch to a template.""" """Test applying a patch to a template."""
......
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