Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
07426283
Commit
07426283
authored
Sep 27, 2013
by
Yutong Zhao
Browse files
Merge pull request #150 from rmcgibbo/gmxbug
Fix bug in gromacs top file parser
parents
167253d5
efd3fedd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
wrappers/python/simtk/openmm/app/gromacstopfile.py
wrappers/python/simtk/openmm/app/gromacstopfile.py
+16
-0
No files found.
wrappers/python/simtk/openmm/app/gromacstopfile.py
View file @
07426283
...
...
@@ -91,6 +91,9 @@ class GromacsTopFile(object):
# A preprocessor command.
fields
=
stripped
.
split
()
command
=
fields
[
0
]
if
len
(
self
.
_ifStack
)
!=
len
(
self
.
_elseStack
):
raise
RuntimeError
(
'#if/#else stack out of sync'
)
if
command
==
'#include'
and
not
ignore
:
# Locate the file to include
name
=
stripped
[
len
(
command
):].
strip
(
'
\t
"<>'
)
...
...
@@ -117,17 +120,29 @@ class GromacsTopFile(object):
raise
ValueError
(
'Illegal line in .top file: '
+
line
)
name
=
fields
[
1
]
self
.
_ifStack
.
append
(
name
in
self
.
_defines
)
self
.
_elseStack
.
append
(
False
)
elif
command
==
'#ifndef'
:
# See whether this block should be ignored.
if
len
(
fields
)
<
2
:
raise
ValueError
(
'Illegal line in .top file: '
+
line
)
name
=
fields
[
1
]
self
.
_ifStack
.
append
(
name
not
in
self
.
_defines
)
self
.
_elseStack
.
append
(
False
)
elif
command
==
'#endif'
:
# Pop an entry off the if stack.
if
len
(
self
.
_ifStack
)
==
0
:
raise
ValueError
(
'Unexpected line in .top file: '
+
line
)
del
(
self
.
_ifStack
[
-
1
])
del
(
self
.
_elseStack
[
-
1
])
elif
command
==
'#else'
:
# Reverse the last entry on the if stack
if
len
(
self
.
_ifStack
)
==
0
:
raise
ValueError
(
'Unexpected line in .top file: '
+
line
)
if
self
.
_elseStack
[
-
1
]:
raise
ValueError
(
'Unexpected line in .top file: '
'#else has already been used '
+
line
)
self
.
_ifStack
[
-
1
]
=
(
not
self
.
_ifStack
[
-
1
])
self
.
_elseStack
[
-
1
]
=
True
elif
not
ignore
:
# A line of data for the current category
...
...
@@ -364,6 +379,7 @@ class GromacsTopFile(object):
self
.
_currentCategory
=
None
self
.
_ifStack
=
[]
self
.
_elseStack
=
[]
self
.
_moleculeTypes
=
{}
self
.
_molecules
=
[]
self
.
_currentMoleculeType
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment