"vscode:/vscode.git/clone" did not exist on "ee3551ab24fb1998ee19ccb2cfa3cdf5400032bf"
Unverified Commit ef02e48d authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2338 from tristanic/master

Allow ForceField to add custom prefix to templates when loading XML files
parents 9ef98fd3 5a06df78
...@@ -184,7 +184,7 @@ class ForceField(object): ...@@ -184,7 +184,7 @@ class ForceField(object):
self._templateGenerators = [] self._templateGenerators = []
self.loadFile(files) self.loadFile(files)
def loadFile(self, files): def loadFile(self, files, resname_prefix=''):
"""Load an XML file and add the definitions from it to this ForceField. """Load an XML file and add the definitions from it to this ForceField.
Parameters Parameters
...@@ -195,6 +195,9 @@ class ForceField(object): ...@@ -195,6 +195,9 @@ class ForceField(object):
directory, a path relative to this module's data subdirectory (for directory, a path relative to this module's data subdirectory (for
built in force fields), or an open file-like object with a read() built in force fields), or an open file-like object with a read()
method from which the forcefield XML data can be loaded. method from which the forcefield XML data can be loaded.
prefix : string
An optional string to be prepended to each residue name found in the
loaded files.
""" """
if isinstance(files, tuple): if isinstance(files, tuple):
...@@ -260,7 +263,7 @@ class ForceField(object): ...@@ -260,7 +263,7 @@ class ForceField(object):
for tree in trees: for tree in trees:
if tree.getroot().find('Residues') is not None: if tree.getroot().find('Residues') is not None:
for residue in tree.getroot().find('Residues').findall('Residue'): for residue in tree.getroot().find('Residues').findall('Residue'):
resName = residue.attrib['name'] resName = resname_prefix+residue.attrib['name']
template = ForceField._TemplateData(resName) template = ForceField._TemplateData(resName)
if 'override' in residue.attrib: if 'override' in residue.attrib:
template.overrideLevel = int(residue.attrib['override']) template.overrideLevel = int(residue.attrib['override'])
......
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