Unverified Commit 0ad62341 authored by Evan Pretti's avatar Evan Pretti Committed by GitHub
Browse files

Fix error message formatting related to bonds to extra sites (#5065)

parent bb3f4f82
......@@ -1888,8 +1888,8 @@ def _findMatchErrors(forcefield, res):
def formatBondDiff(key, diff):
"""Formats a string describing elements associated with a different number of bonds."""
name1 = elem.Element.getByAtomicNumber(key[0]).symbol if key else 'extra site'
name2 = elem.Element.getByAtomicNumber(key[1]).symbol if key else 'extra site'
name1 = elem.Element.getByAtomicNumber(key[0]).symbol if key[0] else 'extra site'
name2 = elem.Element.getByAtomicNumber(key[1]).symbol if key[1] else 'extra site'
return f'{name1}-{name2} bond' + ('' if diff == 1 else 's')
def pickBestMatch(bestMatches):
......
......@@ -987,6 +987,18 @@ class TestForceField(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'No template found for residue.*HOH.*The force field contains no residue templates'):
makeSystem(pdbLines)
# Make water with an extra site and an (invalid) bond to it.
pdbLines = [
'ATOM 0 O HOH A 1 0 0 0 O',
'ATOM 1 H1 HOH A 1 0 0 0 H',
'ATOM 2 H2 HOH A 1 0 0 0 H',
'ATOM 3 M HOH A 1 0 0 0 EP',
'CONECT 0 3'
]
forcefield = ForceField('opc.xml')
with self.assertRaisesRegex(ValueError, 'No template found for residue.*HOH.*The set of atoms matches HOH, but the residue has 1 extra site-O bond too many'):
makeSystem(pdbLines)
def test_Wildcard(self):
"""Test that PeriodicTorsionForces using wildcard ('') for atom types / classes in the ffxml are correctly registered"""
......
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