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
32a5f304
Unverified
Commit
32a5f304
authored
Oct 23, 2023
by
Peter Eastman
Committed by
GitHub
Oct 23, 2023
Browse files
Fixed issues in applying patches (#4279)
parent
10c909dd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
wrappers/python/openmm/app/forcefield.py
wrappers/python/openmm/app/forcefield.py
+17
-1
No files found.
wrappers/python/openmm/app/forcefield.py
View file @
32a5f304
...
@@ -481,6 +481,7 @@ class ForceField(object):
...
@@ -481,6 +481,7 @@ class ForceField(object):
def
registerPatch
(
self
,
patch
):
def
registerPatch
(
self
,
patch
):
"""Register a new patch that can be applied to templates."""
"""Register a new patch that can be applied to templates."""
patch
.
index
=
len
(
self
.
_patches
)
self
.
_patches
[
patch
.
name
]
=
patch
self
.
_patches
[
patch
.
name
]
=
patch
def
registerTemplatePatch
(
self
,
residue
,
patch
,
patchResidueIndex
):
def
registerTemplatePatch
(
self
,
residue
,
patch
,
patchResidueIndex
):
...
@@ -792,6 +793,17 @@ class ForceField(object):
...
@@ -792,6 +793,17 @@ class ForceField(object):
else
:
else
:
self
.
excludeWith
=
self
.
atoms
[
0
]
self
.
excludeWith
=
self
.
atoms
[
0
]
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
ForceField
.
_VirtualSiteData
):
return
False
if
self
.
type
!=
other
.
type
or
self
.
index
!=
other
.
index
or
self
.
atoms
!=
other
.
atoms
or
self
.
excludeWith
!=
other
.
excludeWith
:
return
False
if
self
.
type
in
(
'average2'
,
'average3'
,
'outOfPlane'
):
return
self
.
weights
==
other
.
weights
elif
self
.
type
==
'localCoords'
:
return
self
.
originWeights
==
other
.
originWeights
and
self
.
xWeights
==
other
.
xWeights
and
self
.
yWeights
==
other
.
yWeights
and
self
.
localPos
==
other
.
localPos
return
False
class
_PatchData
(
object
):
class
_PatchData
(
object
):
"""Inner class used to encapsulate data about a patch definition."""
"""Inner class used to encapsulate data about a patch definition."""
def
__init__
(
self
,
name
,
numResidues
):
def
__init__
(
self
,
name
,
numResidues
):
...
@@ -807,6 +819,10 @@ class ForceField(object):
...
@@ -807,6 +819,10 @@ class ForceField(object):
self
.
allAtomNames
=
set
()
self
.
allAtomNames
=
set
()
self
.
virtualSites
=
[[]
for
i
in
range
(
numResidues
)]
self
.
virtualSites
=
[[]
for
i
in
range
(
numResidues
)]
self
.
attributes
=
{}
self
.
attributes
=
{}
self
.
index
=
None
def
__lt__
(
self
,
other
):
return
self
.
index
<
other
.
index
def
createPatchedTemplates
(
self
,
templates
):
def
createPatchedTemplates
(
self
,
templates
):
"""Apply this patch to a set of templates, creating new modified ones."""
"""Apply this patch to a set of templates, creating new modified ones."""
...
@@ -1582,7 +1598,7 @@ def _applyPatchesToMatchResidues(forcefield, data, residues, templateForResidue,
...
@@ -1582,7 +1598,7 @@ def _applyPatchesToMatchResidues(forcefield, data, residues, templateForResidue,
patchedTemplates
=
{}
patchedTemplates
=
{}
for
name
,
template
in
forcefield
.
_templates
.
items
():
for
name
,
template
in
forcefield
.
_templates
.
items
():
if
name
in
forcefield
.
_templatePatches
:
if
name
in
forcefield
.
_templatePatches
:
patches
=
[
forcefield
.
_patches
[
patchName
]
for
patchName
,
patchResidueIndex
in
forcefield
.
_templatePatches
[
name
]
if
forcefield
.
_patches
[
patchName
].
numResidues
==
1
]
patches
=
sorted
(
[
forcefield
.
_patches
[
patchName
]
for
patchName
,
patchResidueIndex
in
forcefield
.
_templatePatches
[
name
]
if
forcefield
.
_patches
[
patchName
].
numResidues
==
1
]
)
if
len
(
patches
)
>
0
:
if
len
(
patches
)
>
0
:
newTemplates
=
[]
newTemplates
=
[]
patchedTemplates
[
name
]
=
newTemplates
patchedTemplates
[
name
]
=
newTemplates
...
...
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