Commit 7cdeded0 authored by peastman's avatar peastman
Browse files

Merge pull request #764 from swails/chambercheck

Add a check and raise an exception if someone tries to use a CHAMBER-style prmtop
parents 54d474a6 42c3cc03
...@@ -173,6 +173,10 @@ class AmberPrmtopFile(object): ...@@ -173,6 +173,10 @@ class AmberPrmtopFile(object):
- ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME. - ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME.
Returns: the newly created System Returns: the newly created System
""" """
if self._prmtop.chamber:
raise ValueError("CHAMBER-style topology file detected. CHAMBER "
"topologies are not supported -- use the native "
"CHARMM files directly.")
methodMap = {ff.NoCutoff:'NoCutoff', methodMap = {ff.NoCutoff:'NoCutoff',
ff.CutoffNonPeriodic:'CutoffNonPeriodic', ff.CutoffNonPeriodic:'CutoffNonPeriodic',
ff.CutoffPeriodic:'CutoffPeriodic', ff.CutoffPeriodic:'CutoffPeriodic',
......
...@@ -119,36 +119,38 @@ class PrmtopLoader(object): ...@@ -119,36 +119,38 @@ class PrmtopLoader(object):
self._raw_data={} self._raw_data={}
self._has_nbfix_terms = False self._has_nbfix_terms = False
fIn=open(inFilename) with open(inFilename, 'r') as fIn:
for line in fIn: for line in fIn:
if line.startswith('%VERSION'): if line.startswith('%VERSION'):
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)
self._flags.append(flag) self._flags.append(flag)
self._raw_data[flag] = [] self._raw_data[flag] = []
elif line.startswith('%FORMAT'): elif line.startswith('%FORMAT'):
format = line.rstrip() format = line.rstrip()
index0=format.index('(') index0=format.index('(')
index1=format.index(')') index1=format.index(')')
format = format[index0+1:index1] format = format[index0+1:index1]
m = FORMAT_RE_PATTERN.search(format) m = FORMAT_RE_PATTERN.search(format)
self._raw_format[self._flags[-1]] = (format, m.group(1), m.group(2), m.group(3), m.group(4)) self._raw_format[self._flags[-1]] = (format, m.group(1), m.group(2), m.group(3), m.group(4))
elif self._flags \ elif self._flags \
and 'TITLE'==self._flags[-1] \ and 'TITLE'==self._flags[-1] \
and not self._raw_data['TITLE']: and not self._raw_data['TITLE']:
self._raw_data['TITLE'] = line.rstrip() self._raw_data['TITLE'] = line.rstrip()
else: else:
flag=self._flags[-1] flag=self._flags[-1]
(format, numItems, itemType, (format, numItems, itemType,
itemLength, itemPrecision) = self._getFormat(flag) itemLength, itemPrecision) = self._getFormat(flag)
iLength=int(itemLength) iLength=int(itemLength)
line = line.rstrip() line = line.rstrip()
for index in range(0, len(line), iLength): for index in range(0, len(line), iLength):
item = line[index:index+iLength] item = line[index:index+iLength]
if item: if item:
self._raw_data[flag].append(item.strip()) self._raw_data[flag].append(item.strip())
fIn.close() # See if this is a CHAMBER-style topology file, which is not supported
# for creating Systems
self.chamber = 'CTITLE' in self._flags
def _getFormat(self, flag=None): def _getFormat(self, flag=None):
if not flag: if not flag:
......
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