-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from OpenBioSim/sync_exscientia
Synchronise with Exscientia remote
- Loading branch information
Showing
34 changed files
with
448 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import warnings | ||
|
||
from .._SireWrappers import Molecule as _Molecule | ||
|
||
|
||
def _mark_alchemical_ion(molecule): | ||
""" | ||
Mark the ion molecule as being alchemical ion. | ||
This enables one to use | ||
* :meth:`~BioSimSpace.Sandpit.Exscientia._SireWrappers._system.System.getAlchemicalIon` to get the alchemical ion. | ||
* :meth:`~BioSimSpace.Sandpit.Exscientia._SireWrappers._system.System.getAlchemicalIonIdx` to get the index of alchemical ion. | ||
* :meth:`~BioSimSpace.Sandpit.Exscientia._SireWrappers._molecule.Molecule.isAlchemicalIon` to check if a molecule is an alchemical ion. | ||
Parameters | ||
---------- | ||
molecule : BioSimSpace._SireWrappers.Molecule | ||
The molecule to be marked as alchemical ion. | ||
Returns | ||
------- | ||
alchemical_ion : BSS._SireWrappers.Molecule | ||
The molecule marked as being alchemical ion. | ||
""" | ||
# Validate input. | ||
|
||
if not isinstance(molecule, _Molecule): | ||
raise TypeError( | ||
"'molecule' must be of type 'BioSimSpace._SireWrappers.Molecule'" | ||
) | ||
|
||
# Cannot decouple a perturbable molecule. | ||
if molecule.isAlchemicalIon(): | ||
warnings.warn("'molecule' has already been marked as alchemical ion!") | ||
|
||
# Create a copy of this molecule. | ||
mol = _Molecule(molecule) | ||
mol_sire = mol._sire_object | ||
|
||
# Edit the molecule | ||
mol_edit = mol_sire.edit() | ||
|
||
mol_edit.setProperty("AlchemicalIon", True) | ||
|
||
# Update the Sire molecule object of the new molecule. | ||
mol._sire_object = mol_edit.commit() | ||
|
||
return mol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import pytest | ||
|
||
import BioSimSpace.Sandpit.Exscientia as BSS | ||
from BioSimSpace.Sandpit.Exscientia.Align._alch_ion import _mark_alchemical_ion | ||
from BioSimSpace.Sandpit.Exscientia._SireWrappers import Molecule | ||
|
||
from tests.conftest import root_fp, has_gromacs | ||
|
||
|
||
@pytest.fixture | ||
def system(): | ||
mol = BSS.IO.readMolecules( | ||
[f"{root_fp}/input/ala.top", f"{root_fp}/input/ala.crd"] | ||
)[0] | ||
system = BSS.Solvent.tip3p(mol, ion_conc=0.15, shell=2 * BSS.Units.Length.nanometer) | ||
return system | ||
|
||
|
||
@pytest.fixture | ||
def alchemical_ion_system(system): | ||
ion = system[-1] | ||
ion = _mark_alchemical_ion(ion) | ||
system.updateMolecules(ion) | ||
return system | ||
|
||
|
||
@pytest.mark.skipif(has_gromacs is False, reason="Requires GROMACS to be installed.") | ||
@pytest.mark.parametrize( | ||
"input_system,isalchem", [("system", False), ("alchemical_ion_system", True)] | ||
) | ||
def test_isAlchemicalIon(input_system, isalchem, request): | ||
system = request.getfixturevalue(input_system) | ||
assert system[-1].isAlchemicalIon() is isalchem | ||
|
||
|
||
@pytest.mark.skipif(has_gromacs is False, reason="Requires GROMACS to be installed.") | ||
@pytest.mark.parametrize( | ||
"input_system,isalchem", [("system", None), ("alchemical_ion_system", True)] | ||
) | ||
def test_getAlchemicalIon(input_system, isalchem, request): | ||
system = request.getfixturevalue(input_system) | ||
ion = system.getAlchemicalIon() | ||
if isalchem is None: | ||
assert ion is None | ||
else: | ||
assert isinstance(ion, Molecule) | ||
|
||
|
||
@pytest.mark.skipif(has_gromacs is False, reason="Requires GROMACS to be installed.") | ||
def test_getAlchemicalIonIdx(alchemical_ion_system): | ||
index = alchemical_ion_system.getAlchemicalIonIdx() | ||
assert index == 680 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.