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
5aa19c2d
Unverified
Commit
5aa19c2d
authored
Nov 07, 2019
by
peastman
Committed by
GitHub
Nov 07, 2019
Browse files
Merge pull request #2464 from peastman/element
Improved determination of elements from Gromacs top files
parents
ba62a938
8316b626
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
13 deletions
+27
-13
wrappers/python/simtk/openmm/app/gromacstopfile.py
wrappers/python/simtk/openmm/app/gromacstopfile.py
+20
-13
wrappers/python/tests/TestGromacsTopFile.py
wrappers/python/tests/TestGromacsTopFile.py
+7
-0
No files found.
wrappers/python/simtk/openmm/app/gromacstopfile.py
View file @
5aa19c2d
...
...
@@ -563,8 +563,11 @@ class GromacsTopFile(object):
if
atomName
in
atomReplacements
:
atomName
=
atomReplacements
[
atomName
]
# Try to
guess
the element.
# Try to
determine
the element.
atomicNumber
=
self
.
_atomTypes
[
fields
[
1
]][
2
]
if
atomicNumber
is
None
:
# Try to guess the element from the name.
upper
=
atomName
.
upper
()
if
upper
.
startswith
(
'CL'
):
element
=
elem
.
chlorine
...
...
@@ -577,6 +580,10 @@ class GromacsTopFile(object):
element
=
elem
.
get_by_symbol
(
atomName
[
0
])
except
KeyError
:
element
=
None
elif
atomicNumber
==
'0'
:
element
=
None
else
:
element
=
elem
.
Element
.
getByAtomicNumber
(
int
(
atomicNumber
))
atoms
.
append
(
top
.
addAtom
(
atomName
,
element
,
r
))
# Add bonds to the topology
...
...
wrappers/python/tests/TestGromacsTopFile.py
View file @
5aa19c2d
...
...
@@ -172,6 +172,13 @@ class TestGromacsTopFile(unittest.TestCase):
top
=
GromacsTopFile
(
'systems/bnz.top'
)
gro
=
GromacsGroFile
(
'systems/bnz.gro'
)
for
atom
in
top
.
topology
.
atoms
():
if
atom
.
name
.
startswith
(
'C'
):
self
.
assertEqual
(
elem
.
carbon
,
atom
.
element
)
elif
atom
.
name
.
startswith
(
'H'
):
self
.
assertEqual
(
elem
.
hydrogen
,
atom
.
element
)
else
:
self
.
assertIsNone
(
atom
.
element
)
system
=
top
.
createSystem
()
self
.
assertEqual
(
26
,
system
.
getNumParticles
())
...
...
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