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
c29c1d57
Commit
c29c1d57
authored
Aug 02, 2013
by
peastman
Browse files
Merge pull request #92 from peastman/master
Speed optimization to GromacsTopFile
parents
ea65f7c2
8060c45f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
wrappers/python/simtk/openmm/app/gromacstopfile.py
wrappers/python/simtk/openmm/app/gromacstopfile.py
+23
-1
No files found.
wrappers/python/simtk/openmm/app/gromacstopfile.py
View file @
c29c1d57
...
...
@@ -463,6 +463,24 @@ class GromacsTopFile(object):
exceptions
=
[]
fudgeQQ
=
float
(
self
.
_defaults
[
4
])
# Build a lookup table to let us process dihedrals more quickly.
dihedralTypeTable
=
{}
for
key
in
self
.
_dihedralTypes
:
if
key
[
1
]
!=
'X'
and
key
[
2
]
!=
'X'
:
if
(
key
[
1
],
key
[
2
])
not
in
dihedralTypeTable
:
dihedralTypeTable
[(
key
[
1
],
key
[
2
])]
=
[]
dihedralTypeTable
[(
key
[
1
],
key
[
2
])].
append
(
key
)
if
(
key
[
2
],
key
[
1
])
not
in
dihedralTypeTable
:
dihedralTypeTable
[(
key
[
2
],
key
[
1
])]
=
[]
dihedralTypeTable
[(
key
[
2
],
key
[
1
])].
append
(
key
)
wildcardDihedralTypes
=
[]
for
key
in
self
.
_dihedralTypes
:
if
key
[
1
]
==
'X'
or
key
[
2
]
==
'X'
:
wildcardDihedralTypes
.
append
(
key
)
for
types
in
dihedralTypeTable
.
itervalues
():
types
.
append
(
key
)
# Loop over molecules and create the specified number of each type.
for
moleculeName
,
moleculeCount
in
self
.
_molecules
:
...
...
@@ -584,7 +602,11 @@ class GromacsTopFile(object):
else
:
# Look for a matching dihedral type.
paramsList
=
None
for
key
in
self
.
_dihedralTypes
:
if
(
types
[
1
],
types
[
2
])
in
dihedralTypeTable
:
dihedralTypes
=
dihedralTypeTable
[(
types
[
1
],
types
[
2
])]
else
:
dihedralTypes
=
wildcardDihedralTypes
for
key
in
dihedralTypes
:
if
all
(
a
==
b
or
a
==
'X'
for
a
,
b
in
zip
(
key
,
types
))
or
all
(
a
==
b
or
a
==
'X'
for
a
,
b
in
zip
(
key
,
reversedTypes
)):
paramsList
=
self
.
_dihedralTypes
[
key
]
if
'X'
not
in
key
:
...
...
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