Skip to content
Open
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
22 changes: 0 additions & 22 deletions src/openfe/protocols/openmm_rfe/hybridtop_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ def _validate_mapping(
ValueError
* If there are more than one mapping or mapping is None
* If the mapping components are not in the alchemical components.
UserWarning
* Mappings which involve element changes in core atoms
"""
# if a single mapping is provided, convert to list
if isinstance(mapping, ComponentMapping):
Expand All @@ -294,26 +292,6 @@ def _validate_mapping(
f"in alchemical components of state{state}"
)

# TODO: remove - this is now the default behaviour?
# Check for element changes in mappings
for m in mapping:
molA = m.componentA.to_rdkit()
molB = m.componentB.to_rdkit()
for i, j in m.componentA_to_componentB.items():
atomA = molA.GetAtomWithIdx(i)
atomB = molB.GetAtomWithIdx(j)
if atomA.GetAtomicNum() != atomB.GetAtomicNum():
wmsg = (
f"Element change in mapping between atoms "
f"Ligand A: {i} (element {atomA.GetAtomicNum()}) and "
f"Ligand B: {j} (element {atomB.GetAtomicNum()})\n"
"No mass scaling is attempted in the hybrid topology, "
"the average mass of the two atoms will be used in the "
"simulation"
)
logger.warning(wmsg)
warnings.warn(wmsg)

@staticmethod
def _validate_smcs(
stateA: ChemicalSystem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import logging
import warnings

import pytest
from openff.units import unit as offunit
Expand Down Expand Up @@ -357,7 +358,8 @@ def test_too_many_prot_comps_error(


def test_element_change_warning(atom_mapping_basic_test_files):
# check a mapping with element change gets rejected early
# in openfe <v1.11, this would raise a warning, but now is acceptable.
# TODO: can remove this test in v1.13 if we want
l1 = atom_mapping_basic_test_files["2-methylnaphthalene"]
l2 = atom_mapping_basic_test_files["2-naftanol"]

Expand All @@ -371,11 +373,11 @@ def test_element_change_warning(atom_mapping_basic_test_files):

alchem_comps = {"stateA": [l1], "stateB": [l2]}

with pytest.warns(UserWarning, match="Element change"):
openmm_rfe.RelativeHybridTopologyProtocol._validate_mapping(
[mapping],
alchem_comps,
)
with warnings.catch_warnings(record=True) as record:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can instead remove this test entirely - I just wanted to show how we could do this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think removing it would make sense, but it's greta to see that it's catching this!

warnings.simplefilter("always")
openmm_rfe.RelativeHybridTopologyProtocol._validate_mapping([mapping], alchem_comps)
# there may be other warnings bubbling up, but we make sure mass scaling warning isn't here.
assert not any(["mass scaling" in str(r.message) for r in record])


def test_charge_difference_no_corr(benzene_to_benzoic_mapping):
Expand Down
Loading