"platforms/vscode:/vscode.git/clone" did not exist on "d92e09370ffd3aa31c6dd0ec43162d073765ac43"
Commit d4b1ced1 authored by Stephen Constable's avatar Stephen Constable
Browse files

Fixed field support in group file

The old _is_gro_coord function inexplicably used split() even though
gro files fixed field (nb: the parsing was still done correctly).  Now
it uses fixed field substrings.
parent b0cf367c
...@@ -34,6 +34,7 @@ __version__ = "1.0" ...@@ -34,6 +34,7 @@ __version__ = "1.0"
import os import os
import sys import sys
from string import strip
from simtk.openmm import Vec3 from simtk.openmm import Vec3
from simtk.openmm.app.internal.unitcell import reducePeriodicBoxVectors from simtk.openmm.app.internal.unitcell import reducePeriodicBoxVectors
from re import sub, match from re import sub, match
...@@ -69,14 +70,14 @@ def _is_gro_coord(line): ...@@ -69,14 +70,14 @@ def _is_gro_coord(line):
@param[in] line The line to be tested @param[in] line The line to be tested
""" """
sline = line.split() # data lines are fixed field
if len(sline) == 6 or len(sline) == 9: fields = []
return all([_isint(sline[2]), _isfloat(sline[3]), _isfloat(sline[4]), _isfloat(sline[5])]) fields.append(strip(line[16:20])) # atom number
#handles case when first entry is split fields.append(strip(line[21:28])) # x coord
elif len(sline) == 7: fields.append(strip(line[29:36])) # y coord
return all([_isint(sline[3]), _isfloat(sline[4]), _isfloat(sline[5]), _isfloat(sline[6])]) fields.append(strip(line[37:44])) # z coord
elif len(sline) == 5 or len(sline) == 8: if (all([f != '' for f in fields])): # check for empty fields
return all([_isint(line[15:20]), _isfloat(sline[2]), _isfloat(sline[3]), _isfloat(sline[4])]) return all([_isint(fields[0]), _isfloat(fields[1]), _isfloat(fields[2]), _isfloat(fields[3])])
else: else:
return 0 return 0
......
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