diff --git a/python/BioSimSpace/Parameters/__init__.py b/python/BioSimSpace/Parameters/__init__.py index b56a9535..c2bc6c77 100644 --- a/python/BioSimSpace/Parameters/__init__.py +++ b/python/BioSimSpace/Parameters/__init__.py @@ -40,7 +40,7 @@ import BioSimSpace as BSS - print(BSS.Parameters.force_fields()) + print(BSS.Parameters.forceFields()) Parameterise a molecule using GAFF. diff --git a/python/BioSimSpace/Parameters/_parameters.py b/python/BioSimSpace/Parameters/_parameters.py index d9db81fd..846debdf 100644 --- a/python/BioSimSpace/Parameters/_parameters.py +++ b/python/BioSimSpace/Parameters/_parameters.py @@ -74,7 +74,7 @@ def parameterise( string. forcefield : str - The force field. Run BioSimSpace.Parameters.force_fields() to get a + The force field. Run BioSimSpace.Parameters.forceFields() to get a list of the supported force fields. ensure_compatible : bool diff --git a/python/BioSimSpace/Sandpit/Exscientia/Parameters/__init__.py b/python/BioSimSpace/Sandpit/Exscientia/Parameters/__init__.py index b56a9535..c2bc6c77 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/Parameters/__init__.py +++ b/python/BioSimSpace/Sandpit/Exscientia/Parameters/__init__.py @@ -40,7 +40,7 @@ import BioSimSpace as BSS - print(BSS.Parameters.force_fields()) + print(BSS.Parameters.forceFields()) Parameterise a molecule using GAFF. diff --git a/python/BioSimSpace/Sandpit/Exscientia/Parameters/_parameters.py b/python/BioSimSpace/Sandpit/Exscientia/Parameters/_parameters.py index d9db81fd..846debdf 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/Parameters/_parameters.py +++ b/python/BioSimSpace/Sandpit/Exscientia/Parameters/_parameters.py @@ -74,7 +74,7 @@ def parameterise( string. forcefield : str - The force field. Run BioSimSpace.Parameters.force_fields() to get a + The force field. Run BioSimSpace.Parameters.forceFields() to get a list of the supported force fields. ensure_compatible : bool diff --git a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py index d59a6edb..33a5f2f1 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py +++ b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py @@ -983,9 +983,9 @@ def makeCompatibleWith( propty = mol1.property(_property_map[prop]) # Try making it compatible with the original molecule. - if hasattr(propty, "makeCompatibleWith"): + if hasattr(propty, "make_compatible_with"): try: - propty = propty.makeCompatibleWith( + propty = propty.make_compatible_with( mol0, inv_matches ) except Exception as e: @@ -1188,9 +1188,9 @@ def makeCompatibleWith( propty = mol.property(prop) # Try making the property compatible with the original molecule. - if hasattr(propty, "makeCompatibleWith"): + if hasattr(propty, "make_compatible_with"): try: - propty = propty.makeCompatibleWith(mol0, inv_matches) + propty = propty.make_compatible_with(mol0, inv_matches) except Exception as e: msg = "Incompatible property: %s" % prop if _isVerbose(): diff --git a/python/BioSimSpace/_SireWrappers/_molecule.py b/python/BioSimSpace/_SireWrappers/_molecule.py index 8c7510ef..e74738ad 100644 --- a/python/BioSimSpace/_SireWrappers/_molecule.py +++ b/python/BioSimSpace/_SireWrappers/_molecule.py @@ -923,9 +923,9 @@ def makeCompatibleWith( propty = mol1.property(_property_map[prop]) # Try making it compatible with the original molecule. - if hasattr(propty, "makeCompatibleWith"): + if hasattr(propty, "make_compatible_with"): try: - propty = propty.makeCompatibleWith( + propty = propty.make_compatible_with( mol0, inv_matches ) except Exception as e: @@ -1128,9 +1128,9 @@ def makeCompatibleWith( propty = mol.property(prop) # Try making the property compatible with the original molecule. - if hasattr(propty, "makeCompatibleWith"): + if hasattr(propty, "make_compatible_with"): try: - propty = propty.makeCompatibleWith(mol0, inv_matches) + propty = propty.make_compatible_with(mol0, inv_matches) except Exception as e: msg = "Incompatible property: %s" % prop if _isVerbose(): diff --git a/tests/Sandpit/Exscientia/_SireWrappers/test_molecule.py b/tests/Sandpit/Exscientia/_SireWrappers/test_molecule.py index 9ab6516f..15fe4ae4 100644 --- a/tests/Sandpit/Exscientia/_SireWrappers/test_molecule.py +++ b/tests/Sandpit/Exscientia/_SireWrappers/test_molecule.py @@ -143,3 +143,34 @@ def test_lipid(lipid): mol._sire_object = c.commit() assert mol.isLipid() is lipid + + +@pytest.mark.skipif(has_amber is False, reason="Requires AMBER to be installed.") +def test_makeCompatibleWith_regression(): + """Test that makeCompatibleWith works correctly for a known regression case.""" + + import sire as sr + + # Load the BACE protein. + protein_xtal = BSS.IO.readMolecules(BSS.IO.expand(url, "bace.pdb")) + + # Remove waters. + protein = protein_xtal[0].extract( + [atom.index() for atom in protein_xtal[0].search("not resname WAT").atoms()] + ) + + # Parameterise with ff14SB. + protein = BSS.Parameters.ff14SB( + protein, work_dir="debug", ensure_compatible=False + ).getMolecule() + + # Convert to a Sire System and compute the energy. + system = sr.system.System(protein.toSystem()._sire_object) + nrg_compatible = system.energy().value() + + # Load in the tLEaP-generated system and compute the energy. + system = sr.load("debug/leap.crd", "debug/leap.top") + nrg_leap = system.energy().value() + + # Make sure the energies are approximately equal. + assert nrg_compatible == pytest.approx(nrg_leap, rel=1e-5) diff --git a/tests/_SireWrappers/test_molecule.py b/tests/_SireWrappers/test_molecule.py index 5812ecff..72aff7f1 100644 --- a/tests/_SireWrappers/test_molecule.py +++ b/tests/_SireWrappers/test_molecule.py @@ -115,3 +115,34 @@ def test_extract(system): # Make sure the numbers are different. assert partial_mol.number() != mol.number() + + +@pytest.mark.skipif(has_amber is False, reason="Requires AMBER to be installed.") +def test_makeCompatibleWith_regression(): + """Test that makeCompatibleWith works correctly for a known regression case.""" + + import sire as sr + + # Load the BACE protein. + protein_xtal = BSS.IO.readMolecules(BSS.IO.expand(url, "bace.pdb")) + + # Remove waters. + protein = protein_xtal[0].extract( + [atom.index() for atom in protein_xtal[0].search("not resname WAT").atoms()] + ) + + # Parameterise with ff14SB. + protein = BSS.Parameters.ff14SB( + protein, work_dir="debug", ensure_compatible=False + ).getMolecule() + + # Convert to a Sire System and compute the energy. + system = sr.system.System(protein.toSystem()._sire_object) + nrg_compatible = system.energy().value() + + # Load in the tLEaP-generated system and compute the energy. + system = sr.load("debug/leap.crd", "debug/leap.top") + nrg_leap = system.energy().value() + + # Make sure the energies are approximately equal. + assert nrg_compatible == pytest.approx(nrg_leap, rel=1e-5)