Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #347 #361

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/BioSimSpace/Parameters/_Protocol/_amber.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ def __init__(
net_charge=None,
ensure_compatible=True,
property_map={},
**kwargs,
):
"""
Constructor.
Expand Down Expand Up @@ -873,6 +874,10 @@ def __init__(
A dictionary that maps system "properties" to their user defined
values. This allows the user to refer to properties with their
own naming scheme, e.g. { "charge" : "my-charge" }

**kwargs: dict
Additional keyword arguments. These can be used to pass custom
parameters to the Antechamber program.
"""

if type(version) is not int:
Expand Down Expand Up @@ -912,6 +917,11 @@ def __init__(
"'net_charge' must be of type 'int', or `BioSimSpace.Types.Charge'"
)

# Check the kwargs to see whether acdoctor is enabled.
self._acdoctor = kwargs.get("acdoctor", True)
if not isinstance(self._acdoctor, bool):
raise TypeError("'acdoctor' must be of type 'bool'")

# Set the version.
self._version = version

Expand Down Expand Up @@ -1086,6 +1096,10 @@ def run(self, molecule, work_dir=None, queue=None):
charge,
)

# Disable acdoctor if requested.
if not self._acdoctor:
command += " -dr no"

with open(_os.path.join(str(work_dir), "README.txt"), "w") as file:
# Write the command to file.
file.write("# Antechamber was run with the following command:\n")
Expand Down
2 changes: 2 additions & 0 deletions python/BioSimSpace/Parameters/_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def gaff(
charge_method=charge_method,
ensure_compatible=ensure_compatible,
property_map=property_map,
**kwargs,
)

# Run the parameterisation protocol in the background and return
Expand Down Expand Up @@ -460,6 +461,7 @@ def gaff2(
charge_method=charge_method,
ensure_compatible=ensure_compatible,
property_map=property_map,
**kwargs,
)

# Run the parameterisation protocol in the background and return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ def __init__(
net_charge=None,
ensure_compatible=True,
property_map={},
**kwargs,
):
"""
Constructor.
Expand Down Expand Up @@ -873,6 +874,10 @@ def __init__(
A dictionary that maps system "properties" to their user defined
values. This allows the user to refer to properties with their
own naming scheme, e.g. { "charge" : "my-charge" }

**kwargs: dict
Additional keyword arguments. These can be used to pass custom
parameters to the Antechamber program.
"""

if type(version) is not int:
Expand Down Expand Up @@ -912,6 +917,11 @@ def __init__(
"'net_charge' must be of type 'int', or `BioSimSpace.Types.Charge'"
)

# Check the kwargs to see whether acdoctor is enabled.
self._acdoctor = kwargs.get("acdoctor", True)
if not isinstance(self._acdoctor, bool):
raise TypeError("'acdoctor' must be of type 'bool'")

# Set the version.
self._version = version

Expand Down Expand Up @@ -1086,6 +1096,10 @@ def run(self, molecule, work_dir=None, queue=None):
charge,
)

# Disable acdoctor if requested.
if not self._acdoctor:
command += " -dr no"

with open(_os.path.join(str(work_dir), "README.txt"), "w") as file:
# Write the command to file.
file.write("# Antechamber was run with the following command:\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def gaff(
charge_method=charge_method,
ensure_compatible=ensure_compatible,
property_map=property_map,
**kwargs,
)

# Run the parameterisation protocol in the background and return
Expand Down Expand Up @@ -460,6 +461,7 @@ def gaff2(
charge_method=charge_method,
ensure_compatible=ensure_compatible,
property_map=property_map,
**kwargs,
)

# Run the parameterisation protocol in the background and return
Expand Down
21 changes: 21 additions & 0 deletions tests/Parameters/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,24 @@ def test_smiles_stereo():

# Make sure the SMILES strings are the same.
assert rdmol0_smiles == rdmol1_smiles


@pytest.mark.skipif(
has_antechamber is False or has_tleap is False,
reason="Requires AmberTools/antechamber and tLEaP to be installed.",
)
def test_acdoctor():
"""
Test that parameterising negatively charged molecules works when acdoctor
is disabled.
"""

# Load the molecule.
mol = BSS.IO.readMolecules(f"{url}/negative_charge.sdf")[0]

# Make sure parameterisation fails when acdoctor is enabled.
with pytest.raises(BSS._Exceptions.ParameterisationError):
BSS.Parameters.gaff(mol).getMolecule()

# Make sure parameterisation works when acdoctor is disabled.
mol = BSS.Parameters.gaff(mol, acdoctor=False).getMolecule()
21 changes: 21 additions & 0 deletions tests/Sandpit/Exscientia/Parameters/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,24 @@ def test_smiles_stereo():

# Make sure the SMILES strings are the same.
assert rdmol0_smiles == rdmol1_smiles


@pytest.mark.skipif(
has_antechamber is False or has_tleap is False,
reason="Requires AmberTools/antechamber and tLEaP to be installed.",
)
def test_acdoctor():
"""
Test that parameterising negatively charged molecules works when acdoctor
is disabled.
"""

# Load the molecule.
mol = BSS.IO.readMolecules(f"{url}/negative_charge.sdf")[0]

# Make sure parameterisation fails when acdoctor is enabled.
with pytest.raises(BSS._Exceptions.ParameterisationError):
BSS.Parameters.gaff(mol).getMolecule()

# Make sure parameterisation works when acdoctor is disabled.
mol = BSS.Parameters.gaff(mol, acdoctor=False).getMolecule()
Loading