Commit 3c328f39 authored by peastman's avatar peastman
Browse files

Merge pull request #892 from swails/catch_chamber

Better error catch for using chamber prmtops
parents 7b67c27b 486b97c7
...@@ -127,6 +127,10 @@ class PrmtopLoader(object): ...@@ -127,6 +127,10 @@ class PrmtopLoader(object):
tag, self._prmtopVersion = line.rstrip().split(None, 1) tag, self._prmtopVersion = line.rstrip().split(None, 1)
elif line.startswith('%FLAG'): elif line.startswith('%FLAG'):
tag, flag = line.rstrip().split(None, 1) tag, flag = line.rstrip().split(None, 1)
if flag == 'CTITLE':
raise TypeError('CHAMBER-style topology files are not supported here. '
'Consider using the CHARMM files directly with CharmmPsfFile '
'or ParmEd (where CHAMBER topologies are supported)')
self._flags.append(flag) self._flags.append(flag)
self._raw_data[flag] = [] self._raw_data[flag] = []
elif line.startswith('%FORMAT'): elif line.startswith('%FORMAT'):
......
...@@ -316,7 +316,17 @@ class TestAmberPrmtopFile(unittest.TestCase): ...@@ -316,7 +316,17 @@ class TestAmberPrmtopFile(unittest.TestCase):
simulation.reporters.append(DCDReporter(fname, 1)) # This is an explicit test for the bugs in issue #850 simulation.reporters.append(DCDReporter(fname, 1)) # This is an explicit test for the bugs in issue #850
simulation.step(5) simulation.step(5)
os.remove(fname) os.remove(fname)
def testChamber(self):
""" Tests that Chamber prmtops fail with proper error message """
self.assertRaises(TypeError, lambda: AmberPrmtopFile('systems/ala3_solv.parm7'))
try:
parm = AmberPrmtopFile('systems/ala3_solv.parm7')
# Should not make it past here
self.assertTrue(False)
except TypeError as e:
# Make sure it says something about chamber
self.assertTrue('chamber' in str(e).lower())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
This diff is collapsed.
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