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
3775794f
Unverified
Commit
3775794f
authored
Mar 04, 2025
by
Peter Eastman
Committed by
GitHub
Mar 04, 2025
Browse files
Use cell list to speed up addHydrogens() (#4816)
parent
a6545a1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
wrappers/python/openmm/app/modeller.py
wrappers/python/openmm/app/modeller.py
+21
-3
No files found.
wrappers/python/openmm/app/modeller.py
View file @
3775794f
...
...
@@ -871,6 +871,9 @@ class Modeller(object):
newResidueTemplates
=
{}
newIndices
=
[]
acceptors
=
[
atom
for
atom
in
self
.
topology
.
atoms
()
if
atom
.
element
in
(
elem
.
oxygen
,
elem
.
nitrogen
)]
positions
=
self
.
positions
.
value_in_unit
(
nanometer
)
acceptorPositions
=
[
positions
[
a
.
index
]
for
a
in
acceptors
]
cells
=
_CellList
(
acceptorPositions
,
0.35
,
None
,
False
)
for
chain
in
self
.
topology
.
chains
():
newChain
=
newTopology
.
addChain
(
chain
.
id
)
for
residue
in
chain
.
residues
():
...
...
@@ -927,14 +930,21 @@ class Modeller(object):
nd1IsBonded
=
False
ne2IsBonded
=
False
for
acceptor
in
acceptors
:
for
acceptorIndex
in
cells
.
neighbors
(
nd1Pos
.
value_in_unit
(
nanometer
)):
acceptor
=
acceptors
[
acceptorIndex
]
if
acceptor
.
residue
!=
residue
:
acceptorPos
=
self
.
positions
[
acceptor
.
index
]
if
isHbond
(
nd1Pos
,
hd1Pos
,
acceptorPos
):
nd1IsBonded
=
True
break
if
isHbond
(
ne2Pos
,
he2Pos
,
acceptorPos
):
ne2IsBonded
=
True
if
not
nd1IsBonded
:
for
acceptorIndex
in
cells
.
neighbors
(
ne2Pos
.
value_in_unit
(
nanometer
)):
acceptor
=
acceptors
[
acceptorIndex
]
if
acceptor
.
residue
!=
residue
:
acceptorPos
=
self
.
positions
[
acceptor
.
index
]
if
isHbond
(
ne2Pos
,
he2Pos
,
acceptorPos
):
nd1IsBonded
=
True
break
if
ne2IsBonded
and
not
nd1IsBonded
:
variant
=
'HIE'
else
:
...
...
@@ -1664,6 +1674,14 @@ class _CellList(object):
"""This class organizes atom positions into cells, so the neighbors of a point can be quickly retrieved"""
def
__init__
(
self
,
positions
,
maxCutoff
,
vectors
,
periodic
):
if
vectors
is
None
:
if
len
(
positions
)
==
0
:
vectors
=
(
Vec3
(
maxCutoff
,
0
,
0
),
Vec3
(
0
,
maxCutoff
,
0
),
Vec3
(
0
,
0
,
maxCutoff
))
else
:
minPos
=
[
min
((
pos
[
i
]
for
pos
in
positions
))
for
i
in
range
(
3
)]
maxPos
=
[
max
((
pos
[
i
]
for
pos
in
positions
))
for
i
in
range
(
3
)]
width
=
[
max
(
maxPos
[
i
]
-
minPos
[
i
],
maxCutoff
)
for
i
in
range
(
3
)]
vectors
=
(
Vec3
(
width
[
0
],
0
,
0
),
Vec3
(
0
,
width
[
1
],
0
),
Vec3
(
0
,
0
,
width
[
2
]))
self
.
positions
=
deepcopy
(
positions
)
self
.
cells
=
{}
self
.
numCells
=
tuple
((
max
(
1
,
int
(
floor
(
vectors
[
i
][
i
]
/
maxCutoff
)))
for
i
in
range
(
3
)))
...
...
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