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
3adf8966
"includes/vscode:/vscode.git/clone" did not exist on "6be8481bb6d4f5ab61139ec50b022f7e9892d579"
Unverified
Commit
3adf8966
authored
Aug 16, 2023
by
Peter Eastman
Committed by
GitHub
Aug 16, 2023
Browse files
GromacsTopFile supports [ settles ] directive (#4188)
parent
f67c7b7e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
wrappers/python/openmm/app/gromacstopfile.py
wrappers/python/openmm/app/gromacstopfile.py
+14
-0
wrappers/python/tests/TestGromacsTopFile.py
wrappers/python/tests/TestGromacsTopFile.py
+1
-0
No files found.
wrappers/python/openmm/app/gromacstopfile.py
View file @
3adf8966
...
@@ -278,6 +278,8 @@ class GromacsTopFile(object):
...
@@ -278,6 +278,8 @@ class GromacsTopFile(object):
self
.
_processPair
(
line
)
self
.
_processPair
(
line
)
elif
self
.
_currentCategory
==
'constraints'
:
elif
self
.
_currentCategory
==
'constraints'
:
self
.
_processConstraint
(
line
)
self
.
_processConstraint
(
line
)
elif
self
.
_currentCategory
==
'settles'
:
self
.
_processSettles
(
line
)
elif
self
.
_currentCategory
==
'cmap'
:
elif
self
.
_currentCategory
==
'cmap'
:
self
.
_processCmap
(
line
)
self
.
_processCmap
(
line
)
elif
self
.
_currentCategory
==
'atomtypes'
:
elif
self
.
_currentCategory
==
'atomtypes'
:
...
@@ -411,6 +413,18 @@ class GromacsTopFile(object):
...
@@ -411,6 +413,18 @@ class GromacsTopFile(object):
raise
ValueError
(
'Too few fields in [ constraints ] line: '
+
line
)
raise
ValueError
(
'Too few fields in [ constraints ] line: '
+
line
)
self
.
_currentMoleculeType
.
constraints
.
append
(
fields
)
self
.
_currentMoleculeType
.
constraints
.
append
(
fields
)
def
_processSettles
(
self
,
line
):
"""Process a line in the [ settles ] category."""
if
self
.
_currentMoleculeType
is
None
:
raise
ValueError
(
'Found [ settles ] section before [ moleculetype ]'
)
fields
=
line
.
split
()
if
len
(
fields
)
<
4
:
raise
ValueError
(
'Too few fields in [ settles ] line: '
+
line
)
atom
=
int
(
fields
[
0
])
self
.
_currentMoleculeType
.
constraints
.
append
([
str
(
atom
),
str
(
atom
+
1
),
fields
[
1
],
fields
[
2
]])
self
.
_currentMoleculeType
.
constraints
.
append
([
str
(
atom
),
str
(
atom
+
2
),
fields
[
1
],
fields
[
2
]])
self
.
_currentMoleculeType
.
constraints
.
append
([
str
(
atom
+
1
),
str
(
atom
+
2
),
fields
[
1
],
fields
[
3
]])
def
_processCmap
(
self
,
line
):
def
_processCmap
(
self
,
line
):
"""Process a line in the [ cmaps ] category."""
"""Process a line in the [ cmaps ] category."""
if
self
.
_currentMoleculeType
is
None
:
if
self
.
_currentMoleculeType
is
None
:
...
...
wrappers/python/tests/TestGromacsTopFile.py
View file @
3adf8966
...
@@ -218,6 +218,7 @@ class TestGromacsTopFile(unittest.TestCase):
...
@@ -218,6 +218,7 @@ class TestGromacsTopFile(unittest.TestCase):
"""Test a three particle virtual site."""
"""Test a three particle virtual site."""
top
=
GromacsTopFile
(
'systems/tip4pew.top'
)
top
=
GromacsTopFile
(
'systems/tip4pew.top'
)
system
=
top
.
createSystem
()
system
=
top
.
createSystem
()
self
.
assertEqual
(
3
,
system
.
getNumConstraints
())
self
.
assertTrue
(
system
.
isVirtualSite
(
3
))
self
.
assertTrue
(
system
.
isVirtualSite
(
3
))
vs
=
system
.
getVirtualSite
(
3
)
vs
=
system
.
getVirtualSite
(
3
)
self
.
assertIsInstance
(
vs
,
ThreeParticleAverageSite
)
self
.
assertIsInstance
(
vs
,
ThreeParticleAverageSite
)
...
...
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