Skip to content

Commit b530cb1

Browse files
authored
Merge pull request #497 from OpenBioSim/fix_496
Fix issue #496
2 parents 2248207 + 0e9ba9c commit b530cb1

8 files changed

Lines changed: 74 additions & 12 deletions

File tree

python/BioSimSpace/Parameters/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
4141
import BioSimSpace as BSS
4242
43-
print(BSS.Parameters.force_fields())
43+
print(BSS.Parameters.forceFields())
4444
4545
Parameterise a molecule using GAFF.
4646

python/BioSimSpace/Parameters/_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def parameterise(
7474
string.
7575
7676
forcefield : str
77-
The force field. Run BioSimSpace.Parameters.force_fields() to get a
77+
The force field. Run BioSimSpace.Parameters.forceFields() to get a
7878
list of the supported force fields.
7979
8080
ensure_compatible : bool

python/BioSimSpace/Sandpit/Exscientia/Parameters/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
4141
import BioSimSpace as BSS
4242
43-
print(BSS.Parameters.force_fields())
43+
print(BSS.Parameters.forceFields())
4444
4545
Parameterise a molecule using GAFF.
4646

python/BioSimSpace/Sandpit/Exscientia/Parameters/_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def parameterise(
7474
string.
7575
7676
forcefield : str
77-
The force field. Run BioSimSpace.Parameters.force_fields() to get a
77+
The force field. Run BioSimSpace.Parameters.forceFields() to get a
7878
list of the supported force fields.
7979
8080
ensure_compatible : bool

python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,9 @@ def makeCompatibleWith(
983983
propty = mol1.property(_property_map[prop])
984984

985985
# Try making it compatible with the original molecule.
986-
if hasattr(propty, "makeCompatibleWith"):
986+
if hasattr(propty, "make_compatible_with"):
987987
try:
988-
propty = propty.makeCompatibleWith(
988+
propty = propty.make_compatible_with(
989989
mol0, inv_matches
990990
)
991991
except Exception as e:
@@ -1188,9 +1188,9 @@ def makeCompatibleWith(
11881188
propty = mol.property(prop)
11891189

11901190
# Try making the property compatible with the original molecule.
1191-
if hasattr(propty, "makeCompatibleWith"):
1191+
if hasattr(propty, "make_compatible_with"):
11921192
try:
1193-
propty = propty.makeCompatibleWith(mol0, inv_matches)
1193+
propty = propty.make_compatible_with(mol0, inv_matches)
11941194
except Exception as e:
11951195
msg = "Incompatible property: %s" % prop
11961196
if _isVerbose():

python/BioSimSpace/_SireWrappers/_molecule.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,9 @@ def makeCompatibleWith(
923923
propty = mol1.property(_property_map[prop])
924924

925925
# Try making it compatible with the original molecule.
926-
if hasattr(propty, "makeCompatibleWith"):
926+
if hasattr(propty, "make_compatible_with"):
927927
try:
928-
propty = propty.makeCompatibleWith(
928+
propty = propty.make_compatible_with(
929929
mol0, inv_matches
930930
)
931931
except Exception as e:
@@ -1128,9 +1128,9 @@ def makeCompatibleWith(
11281128
propty = mol.property(prop)
11291129

11301130
# Try making the property compatible with the original molecule.
1131-
if hasattr(propty, "makeCompatibleWith"):
1131+
if hasattr(propty, "make_compatible_with"):
11321132
try:
1133-
propty = propty.makeCompatibleWith(mol0, inv_matches)
1133+
propty = propty.make_compatible_with(mol0, inv_matches)
11341134
except Exception as e:
11351135
msg = "Incompatible property: %s" % prop
11361136
if _isVerbose():

tests/Sandpit/Exscientia/_SireWrappers/test_molecule.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,34 @@ def test_lipid(lipid):
143143
mol._sire_object = c.commit()
144144

145145
assert mol.isLipid() is lipid
146+
147+
148+
@pytest.mark.skipif(has_amber is False, reason="Requires AMBER to be installed.")
149+
def test_makeCompatibleWith_regression():
150+
"""Test that makeCompatibleWith works correctly for a known regression case."""
151+
152+
import sire as sr
153+
154+
# Load the BACE protein.
155+
protein_xtal = BSS.IO.readMolecules(BSS.IO.expand(url, "bace.pdb"))
156+
157+
# Remove waters.
158+
protein = protein_xtal[0].extract(
159+
[atom.index() for atom in protein_xtal[0].search("not resname WAT").atoms()]
160+
)
161+
162+
# Parameterise with ff14SB.
163+
protein = BSS.Parameters.ff14SB(
164+
protein, work_dir="debug", ensure_compatible=False
165+
).getMolecule()
166+
167+
# Convert to a Sire System and compute the energy.
168+
system = sr.system.System(protein.toSystem()._sire_object)
169+
nrg_compatible = system.energy().value()
170+
171+
# Load in the tLEaP-generated system and compute the energy.
172+
system = sr.load("debug/leap.crd", "debug/leap.top")
173+
nrg_leap = system.energy().value()
174+
175+
# Make sure the energies are approximately equal.
176+
assert nrg_compatible == pytest.approx(nrg_leap, rel=1e-5)

tests/_SireWrappers/test_molecule.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,34 @@ def test_extract(system):
115115

116116
# Make sure the numbers are different.
117117
assert partial_mol.number() != mol.number()
118+
119+
120+
@pytest.mark.skipif(has_amber is False, reason="Requires AMBER to be installed.")
121+
def test_makeCompatibleWith_regression():
122+
"""Test that makeCompatibleWith works correctly for a known regression case."""
123+
124+
import sire as sr
125+
126+
# Load the BACE protein.
127+
protein_xtal = BSS.IO.readMolecules(BSS.IO.expand(url, "bace.pdb"))
128+
129+
# Remove waters.
130+
protein = protein_xtal[0].extract(
131+
[atom.index() for atom in protein_xtal[0].search("not resname WAT").atoms()]
132+
)
133+
134+
# Parameterise with ff14SB.
135+
protein = BSS.Parameters.ff14SB(
136+
protein, work_dir="debug", ensure_compatible=False
137+
).getMolecule()
138+
139+
# Convert to a Sire System and compute the energy.
140+
system = sr.system.System(protein.toSystem()._sire_object)
141+
nrg_compatible = system.energy().value()
142+
143+
# Load in the tLEaP-generated system and compute the energy.
144+
system = sr.load("debug/leap.crd", "debug/leap.top")
145+
nrg_leap = system.energy().value()
146+
147+
# Make sure the energies are approximately equal.
148+
assert nrg_compatible == pytest.approx(nrg_leap, rel=1e-5)

0 commit comments

Comments
 (0)