Unverified Commit a00aa613 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Support initialization scripts in force fields (#3167)

parent a8865f61
......@@ -330,7 +330,7 @@ class ForceField(object):
self.registerTemplatePatch(resName, patchName, 0)
self.registerResidueTemplate(template)
# Load the patch defintions.
# Load the patch definitions.
for tree in trees:
if tree.getroot().find('Patches') is not None:
......@@ -411,6 +411,12 @@ class ForceField(object):
for node in tree.getroot().findall('Script'):
self.registerScript(node.text)
# Execute initialization scripts.
for tree in trees:
for node in tree.getroot().findall('InitializationScript'):
exec(node.text, locals())
def getGenerators(self):
"""Get the list of all registered generators."""
return self._forces
......
......@@ -1149,6 +1149,19 @@ END"""))
self.assertAlmostEqual(26.10373, propers, delta=propers*1e-3) # DIHEdrals
self.assertAlmostEqual(0.14113, impropers, delta=impropers*1e-3) # IMPRopers
def test_InitializationScript(self):
"""Test that <InitializationScript> tags get executed."""
xml = """
<ForceField>
<InitializationScript>
self.scriptExecuted = True
</InitializationScript>
</ForceField>
"""
ff = ForceField(StringIO(xml))
self.assertTrue(ff.scriptExecuted)
class AmoebaTestForceField(unittest.TestCase):
"""Test the ForceField.createSystem() method with the AMOEBA forcefield."""
......
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