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
23 changes: 23 additions & 0 deletions news/remove_element_change_warning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* A warning is no longer raised by Hybrid Topology Protocols for mappings with element changes in core atoms (`Issue #1961 <https://github.com/OpenFreeEnergy/openfe/issues/1961>`_)

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
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
Expand Up @@ -6,7 +6,6 @@
from openff.units import unit as offunit

import openfe
from openfe import setup
from openfe.protocols import openmm_rfe


Expand Down Expand Up @@ -356,28 +355,6 @@ 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
l1 = atom_mapping_basic_test_files["2-methylnaphthalene"]
l2 = atom_mapping_basic_test_files["2-naftanol"]

# We use the 'old' lomap defaults because the
# basic test files inputs we use aren't fully aligned
mapper = setup.LomapAtomMapper(
time=20, threed=True, max3d=1000.0, element_change=True, seed="", shift=True
)

mapping = next(mapper.suggest_mappings(l1, l2))

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

with pytest.warns(UserWarning, match="Element change"):
openmm_rfe.RelativeHybridTopologyProtocol._validate_mapping(
[mapping],
alchem_comps,
)


def test_charge_difference_no_corr(benzene_to_benzoic_mapping):
wmsg = (
"A charge difference of 1 is observed between the end states. "
Expand Down
Loading