diff --git a/news/remove_element_change_warning.rst b/news/remove_element_change_warning.rst new file mode 100644 index 000000000..10a13fc67 --- /dev/null +++ b/news/remove_element_change_warning.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* A warning is no longer raised by Hybrid Topology Protocols for mappings with element changes in core atoms (`Issue #1961 `_) + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/openfe/protocols/openmm_rfe/hybridtop_protocols.py b/src/openfe/protocols/openmm_rfe/hybridtop_protocols.py index ed83e0459..462524337 100644 --- a/src/openfe/protocols/openmm_rfe/hybridtop_protocols.py +++ b/src/openfe/protocols/openmm_rfe/hybridtop_protocols.py @@ -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): @@ -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, diff --git a/src/openfe/tests/protocols/openmm_rfe/test_hybrid_top_validation.py b/src/openfe/tests/protocols/openmm_rfe/test_hybrid_top_validation.py index 6d5db1249..ab8bb73d1 100644 --- a/src/openfe/tests/protocols/openmm_rfe/test_hybrid_top_validation.py +++ b/src/openfe/tests/protocols/openmm_rfe/test_hybrid_top_validation.py @@ -6,7 +6,6 @@ from openff.units import unit as offunit import openfe -from openfe import setup from openfe.protocols import openmm_rfe @@ -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. "