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

Improved residue indexing in error messages (#4942)

* Improved residue indexing in error messages

* Fixed another one
parent a5156da5
...@@ -1044,7 +1044,7 @@ class ForceField(object): ...@@ -1044,7 +1044,7 @@ class ForceField(object):
t1, m1 = allMatches[0] t1, m1 = allMatches[0]
for t2, m2 in allMatches[1:]: for t2, m2 in allMatches[1:]:
if not t1.areParametersIdentical(t2, m1, m2): if not t1.areParametersIdentical(t2, m1, m2):
raise Exception('Multiple non-identical matching templates found for residue %d (%s): %s.' % (res.index+1, res.name, ', '.join(match[0].name for match in allMatches))) raise Exception('Multiple non-identical matching templates found for residue %d (%s): %s.' % (res.index, res.name, ', '.join(match[0].name for match in allMatches)))
template = allMatches[0][0] template = allMatches[0][0]
matches = allMatches[0][1] matches = allMatches[0][1]
return [template, matches] return [template, matches]
...@@ -1436,7 +1436,7 @@ class ForceField(object): ...@@ -1436,7 +1436,7 @@ class ForceField(object):
template = self._templates[tname] template = self._templates[tname]
matches = compiled.matchResidueToTemplate(res, template, data.bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) matches = compiled.matchResidueToTemplate(res, template, data.bondedToAtom, ignoreExternalBonds, ignoreExtraParticles)
if matches is None: if matches is None:
raise Exception('User-supplied template %s does not match the residue %d (%s)' % (tname, res.index+1, res.name)) raise Exception('User-supplied template %s does not match the residue %d (%s)' % (tname, res.index, res.name))
else: else:
# Attempt to match one of the existing templates. # Attempt to match one of the existing templates.
[template, matches] = self._getResidueTemplateMatches(res, data.bondedToAtom, ignoreExternalBonds=ignoreExternalBonds, ignoreExtraParticles=ignoreExtraParticles) [template, matches] = self._getResidueTemplateMatches(res, data.bondedToAtom, ignoreExternalBonds=ignoreExternalBonds, ignoreExtraParticles=ignoreExtraParticles)
...@@ -1471,7 +1471,7 @@ class ForceField(object): ...@@ -1471,7 +1471,7 @@ class ForceField(object):
# We successfully generated a residue template. Break out of the for loop. # We successfully generated a residue template. Break out of the for loop.
break break
if matches is None: if matches is None:
raise ValueError('No template found for residue %d (%s). %s For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#template' % (res.index+1, res.name, _findMatchErrors(self, res))) raise ValueError('No template found for residue %d (%s). %s For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#template' % (res.index, res.name, _findMatchErrors(self, res)))
else: else:
if recordParameters: if recordParameters:
data.recordMatchedAtomParameters(res, template, matches) data.recordMatchedAtomParameters(res, template, matches)
......
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