Commit 895f8dac authored by Peter Eastman's avatar Peter Eastman
Browse files

Throw an exception if an XML tag specifies both an atom type and an atom class

parent a43e8ece
...@@ -154,12 +154,14 @@ class ForceField(object): ...@@ -154,12 +154,14 @@ class ForceField(object):
else: else:
suffix = str(i+1) suffix = str(i+1)
classAttrib = 'class'+suffix classAttrib = 'class'+suffix
typeAttrib = 'type'+suffix
if classAttrib in attrib: if classAttrib in attrib:
if typeAttrib in attrib:
raise ValueError('Tag specifies both a type and a class for the same atom: '+etree.tostring(node))
if attrib[classAttrib] not in self._atomClasses: if attrib[classAttrib] not in self._atomClasses:
return None # Unknown atom class return None # Unknown atom class
types.append(self._atomClasses[attrib[classAttrib]]) types.append(self._atomClasses[attrib[classAttrib]])
else: else:
typeAttrib = 'type'+suffix
if typeAttrib not in attrib or attrib[typeAttrib] not in self._atomTypes: if typeAttrib not in attrib or attrib[typeAttrib] not in self._atomTypes:
return None # Unknown atom type return None # Unknown atom type
types.append([attrib[typeAttrib]]) types.append([attrib[typeAttrib]])
......
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