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
d07c0c02
Commit
d07c0c02
authored
Oct 05, 2016
by
peastman
Committed by
GitHub
Oct 05, 2016
Browse files
Merge pull request #1605 from peastman/hbondbug
Bug fixes to building CustomHbondForce
parents
67fc6658
53b6ea1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+9
-5
wrappers/python/tests/TestGenerators.py
wrappers/python/tests/TestGenerators.py
+33
-0
No files found.
wrappers/python/simtk/openmm/app/forcefield.py
View file @
d07c0c02
...
@@ -2760,7 +2760,7 @@ class CustomHbondGenerator(object):
...
@@ -2760,7 +2760,7 @@ class CustomHbondGenerator(object):
for
param
in
element
.
findall
(
'PerAcceptorParameter'
):
for
param
in
element
.
findall
(
'PerAcceptorParameter'
):
generator
.
perAcceptorParams
.
append
(
param
.
attrib
[
'name'
])
generator
.
perAcceptorParams
.
append
(
param
.
attrib
[
'name'
])
for
donor
in
element
.
findall
(
'Donor'
):
for
donor
in
element
.
findall
(
'Donor'
):
types
=
ff
.
_findAtomTypes
(
donor
.
attrib
,
generator
.
particlesPerDonor
)
types
=
ff
.
_findAtomTypes
(
donor
.
attrib
,
3
)[:
generator
.
particlesPerDonor
]
if
None
not
in
types
:
if
None
not
in
types
:
generator
.
donorTypes1
.
append
(
types
[
0
])
generator
.
donorTypes1
.
append
(
types
[
0
])
if
len
(
types
)
>
1
:
if
len
(
types
)
>
1
:
...
@@ -2769,7 +2769,7 @@ class CustomHbondGenerator(object):
...
@@ -2769,7 +2769,7 @@ class CustomHbondGenerator(object):
generator
.
donorTypes3
.
append
(
types
[
2
])
generator
.
donorTypes3
.
append
(
types
[
2
])
generator
.
donorParamValues
.
append
([
float
(
donor
.
attrib
[
param
])
for
param
in
generator
.
perDonorParams
])
generator
.
donorParamValues
.
append
([
float
(
donor
.
attrib
[
param
])
for
param
in
generator
.
perDonorParams
])
for
acceptor
in
element
.
findall
(
'Acceptor'
):
for
acceptor
in
element
.
findall
(
'Acceptor'
):
types
=
ff
.
_findAtomTypes
(
acceptor
.
attrib
,
generator
.
particlesPerAcceptor
)
types
=
ff
.
_findAtomTypes
(
acceptor
.
attrib
,
3
)[:
generator
.
particlesPerAcceptor
]
if
None
not
in
types
:
if
None
not
in
types
:
generator
.
acceptorTypes1
.
append
(
types
[
0
])
generator
.
acceptorTypes1
.
append
(
types
[
0
])
if
len
(
types
)
>
1
:
if
len
(
types
)
>
1
:
...
@@ -2813,8 +2813,10 @@ class CustomHbondGenerator(object):
...
@@ -2813,8 +2813,10 @@ class CustomHbondGenerator(object):
for
i
in
range
(
len
(
self
.
donorTypes1
)):
for
i
in
range
(
len
(
self
.
donorTypes1
)):
types1
=
self
.
donorTypes1
[
i
]
types1
=
self
.
donorTypes1
[
i
]
types2
=
self
.
donorTypes2
[
i
]
types2
=
self
.
donorTypes2
[
i
]
if
(
type1
in
types1
and
type2
in
types2
)
or
(
type1
in
types2
and
type2
in
types1
):
if
type1
in
types1
and
type2
in
types2
:
force
.
addDonor
(
bond
[
0
],
bond
[
1
],
-
1
,
self
.
donorParamValues
[
i
])
force
.
addDonor
(
bond
.
atom1
,
bond
.
atom2
,
-
1
,
self
.
donorParamValues
[
i
])
elif
type1
in
types2
and
type2
in
types1
:
force
.
addDonor
(
bond
.
atom2
,
bond
.
atom1
,
-
1
,
self
.
donorParamValues
[
i
])
else
:
else
:
for
angle
in
data
.
angles
:
for
angle
in
data
.
angles
:
type1
=
data
.
atomType
[
data
.
atoms
[
angle
[
0
]]]
type1
=
data
.
atomType
[
data
.
atoms
[
angle
[
0
]]]
...
@@ -2843,8 +2845,10 @@ class CustomHbondGenerator(object):
...
@@ -2843,8 +2845,10 @@ class CustomHbondGenerator(object):
for
i
in
range
(
len
(
self
.
acceptorTypes1
)):
for
i
in
range
(
len
(
self
.
acceptorTypes1
)):
types1
=
self
.
acceptorTypes1
[
i
]
types1
=
self
.
acceptorTypes1
[
i
]
types2
=
self
.
acceptorTypes2
[
i
]
types2
=
self
.
acceptorTypes2
[
i
]
if
(
type1
in
types1
and
type2
in
types2
)
or
(
type1
in
types2
and
type2
in
types1
)
:
if
type1
in
types1
and
type2
in
types2
:
force
.
addAcceptor
(
bond
.
atom1
,
bond
.
atom2
,
-
1
,
self
.
acceptorParamValues
[
i
])
force
.
addAcceptor
(
bond
.
atom1
,
bond
.
atom2
,
-
1
,
self
.
acceptorParamValues
[
i
])
elif
type1
in
types2
and
type2
in
types1
:
force
.
addAcceptor
(
bond
.
atom2
,
bond
.
atom1
,
-
1
,
self
.
acceptorParamValues
[
i
])
else
:
else
:
for
angle
in
data
.
angles
:
for
angle
in
data
.
angles
:
type1
=
data
.
atomType
[
data
.
atoms
[
angle
[
0
]]]
type1
=
data
.
atomType
[
data
.
atoms
[
angle
[
0
]]]
...
...
wrappers/python/tests/TestGenerators.py
View file @
d07c0c02
...
@@ -67,5 +67,38 @@ class TestGenerators(unittest.TestCase):
...
@@ -67,5 +67,38 @@ class TestGenerators(unittest.TestCase):
self
.
assertTrue
(
tuple
(
hbond
.
getExclusionParticles
(
i
))
in
expectedExclusions
)
self
.
assertTrue
(
tuple
(
hbond
.
getExclusionParticles
(
i
))
in
expectedExclusions
)
def
test_CustomHbondGenerator2
(
self
):
"""Test the generator for CustomHbondForce with different parameters."""
xml
=
"""
<ForceField>
<CustomHbondForce energy="a*b*distance(a1,d1)" particlesPerDonor="2" particlesPerAcceptor="1" bondCutoff="0">
<PerDonorParameter name="a"/>
<PerAcceptorParameter name="b"/>
<Donor class1="N" class2="H" a="3"/>
<Acceptor class1="O" b="2"/>
</CustomHbondForce>
</ForceField>"""
ff
=
ForceField
(
'amber99sb.xml'
,
StringIO
(
xml
))
system
=
ff
.
createSystem
(
self
.
pdb1
.
topology
)
hbond
=
[
f
for
f
in
system
.
getForces
()
if
isinstance
(
f
,
CustomHbondForce
)][
0
]
self
.
assertEqual
(
1
,
hbond
.
getNumPerDonorParameters
())
self
.
assertEqual
(
1
,
hbond
.
getNumPerAcceptorParameters
())
self
.
assertEqual
(
'a'
,
hbond
.
getPerDonorParameterName
(
0
))
self
.
assertEqual
(
'b'
,
hbond
.
getPerAcceptorParameterName
(
0
))
expectedDonors
=
[(
6
,
7
,
-
1
),
(
16
,
17
,
-
1
)]
expectedAcceptors
=
[(
5
,
-
1
,
-
1
),
(
15
,
-
1
,
-
1
)]
self
.
assertEqual
(
len
(
expectedDonors
),
hbond
.
getNumDonors
())
self
.
assertEqual
(
len
(
expectedAcceptors
),
hbond
.
getNumAcceptors
())
for
i
in
range
(
hbond
.
getNumDonors
()):
atom1
,
atom2
,
atom3
,
params
=
hbond
.
getDonorParameters
(
i
)
self
.
assertTrue
((
atom1
,
atom2
,
atom3
)
in
expectedDonors
)
self
.
assertEqual
((
3.0
,),
params
)
for
i
in
range
(
hbond
.
getNumAcceptors
()):
atom1
,
atom2
,
atom3
,
params
=
hbond
.
getAcceptorParameters
(
i
)
self
.
assertTrue
((
atom1
,
atom2
,
atom3
)
in
expectedAcceptors
)
self
.
assertEqual
((
2.0
,),
params
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
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