Skip to content

Commit 591c9b7

Browse files
atravitzmikemhenry
andauthored
deprecate perses functionality (#1857)
* add tests that should fail * add deprecation warnings * news item * raises-> warns fix * Update news/deprecate_perses.rst Co-authored-by: Mike Henry <11765982+mikemhenry@users.noreply.github.com> * add issues link --------- Co-authored-by: Mike Henry <11765982+mikemhenry@users.noreply.github.com>
1 parent f6cb213 commit 591c9b7

File tree

5 files changed

+56
-15
lines changed

5 files changed

+56
-15
lines changed

news/deprecate_perses.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* Perses atom mapper and scorer functionality is deprecated, slated to be removed in ``openfe v2.0``.
12+
This includes ``PersesAtomMapper`` and ``default_perses_scorer``.
13+
14+
**Removed:**
15+
16+
* <news item>
17+
18+
**Fixed:**
19+
20+
* <news item>
21+
22+
**Security:**
23+
24+
* <news item>

src/openfe/setup/atom_mapping/perses_mapper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
77
"""
88

9+
import warnings
10+
911
from gufe.settings.typing import AngstromQuantity
1012
from openff.units import Quantity, unit
1113
from openff.units.openmm import to_openmm
@@ -75,6 +77,10 @@ def __init__(
7577
can be mapped, default: 0.25*unit.angstrom
7678
7779
"""
80+
warnings.warn(
81+
"PersesAtomMapper is deprecated and is planned to be removed in openfe v2.0. If you have questions related to this, please open an issue at https://github.com/OpenFreeEnergy/openfe/issues.",
82+
DeprecationWarning,
83+
)
7884
self.allow_ring_breaking = allow_ring_breaking
7985
self.preserve_chirality = preserve_chirality
8086
self.use_positions = use_positions

src/openfe/setup/atom_mapping/perses_scorers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This code is part of OpenFE and is licensed under the MIT license.
22
# For details, see https://github.com/OpenFreeEnergy/openfe
33

4+
import warnings
45
from typing import Callable
56

67
from openfe.utils import requires_package
@@ -67,6 +68,11 @@ def default_perses_scorer(
6768
-------
6869
float
6970
"""
71+
warnings.warn(
72+
"default_perses_scorer is deprecated and is planned to be removed in openfe v2.0. If you have questions related to this, please open an issue at https://github.com/OpenFreeEnergy/openfe/issues",
73+
DeprecationWarning,
74+
)
75+
7076
score = AtomMapper(use_positions=use_positions).score_mapping(
7177
AtomMapping(
7278
old_mol=mapping.componentA.to_openff(),

src/openfe/tests/setup/atom_mapping/test_perses_atommapper.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_simple(atom_mapping_basic_test_files):
1313
# basic sanity check on the LigandAtomMapper
1414
mol1 = atom_mapping_basic_test_files["methylcyclohexane"]
1515
mol2 = atom_mapping_basic_test_files["toluene"]
16-
17-
mapper = PersesAtomMapper()
16+
with pytest.warns(DeprecationWarning, match="PersesAtomMapper"):
17+
mapper = PersesAtomMapper()
1818

1919
mapping_gen = mapper.suggest_mappings(mol1, mol2)
2020

@@ -31,8 +31,8 @@ def test_generator_length(atom_mapping_basic_test_files):
3131
# generator stops correctly
3232
mol1 = atom_mapping_basic_test_files["methylcyclohexane"]
3333
mol2 = atom_mapping_basic_test_files["toluene"]
34-
35-
mapper = PersesAtomMapper()
34+
with pytest.warns(DeprecationWarning, match="PersesAtomMapper"):
35+
mapper = PersesAtomMapper()
3636

3737
mapping_gen = mapper.suggest_mappings(mol1, mol2)
3838

@@ -45,7 +45,8 @@ def test_generator_length(atom_mapping_basic_test_files):
4545
@skip_if_missing("perses")
4646
def test_empty_atommappings(mol_pair_to_shock_perses_mapper):
4747
mol1, mol2 = mol_pair_to_shock_perses_mapper
48-
mapper = PersesAtomMapper()
48+
with pytest.warns(DeprecationWarning, match="PersesAtomMapper"):
49+
mapper = PersesAtomMapper()
4950

5051
mapping_gen = mapper.suggest_mappings(mol1, mol2)
5152

@@ -59,11 +60,12 @@ def test_empty_atommappings(mol_pair_to_shock_perses_mapper):
5960
@skip_if_missing("openeye")
6061
@skip_if_missing("perses")
6162
def test_dict_round_trip():
62-
# use some none defaults
63-
mapper1 = PersesAtomMapper(
64-
allow_ring_breaking=False,
65-
preserve_chirality=False,
66-
coordinate_tolerance=0.01 * unit.nanometer,
67-
)
68-
mapper2 = PersesAtomMapper.from_dict(mapper1.to_dict())
63+
with pytest.warns(DeprecationWarning, match="PersesAtomMapper"):
64+
# use some none defaults
65+
mapper1 = PersesAtomMapper(
66+
allow_ring_breaking=False,
67+
preserve_chirality=False,
68+
coordinate_tolerance=0.01 * unit.nanometer,
69+
)
70+
mapper2 = PersesAtomMapper.from_dict(mapper1.to_dict())
6971
assert mapper2.to_dict() == mapper1.to_dict()

src/openfe/tests/setup/atom_mapping/test_perses_scorers.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
@pytest.mark.xfail(not USING_OLD_OFF, reason="perses #1108")
1919
def test_perses_normalization_not_using_positions(gufe_atom_mapping_matrix):
2020
# now run the openfe equivalent with the same ligand atom _mappings
21-
scorer = perses_scorers.default_perses_scorer
21+
with pytest.warns(DeprecationWarning, match="default_perses_scorer"):
22+
scorer = perses_scorers.default_perses_scorer
2223
molecule_row = np.max(list(gufe_atom_mapping_matrix.keys())) + 1
2324
norm_scores = np.zeros([molecule_row, molecule_row])
2425

@@ -41,7 +42,8 @@ def test_perses_normalization_not_using_positions(gufe_atom_mapping_matrix):
4142
@skip_if_missing("perses")
4243
@pytest.mark.xfail(not USING_OLD_OFF, reason="perses #1108")
4344
def test_perses_not_implemented_position_using(gufe_atom_mapping_matrix):
44-
scorer = perses_scorers.default_perses_scorer
45+
with pytest.warns(DeprecationWarning, match="default_perses_scorer"):
46+
scorer = perses_scorers.default_perses_scorer
4547

4648
first_key = list(gufe_atom_mapping_matrix.keys())[0]
4749
match_re = "normalizing using positions is not currently implemented"
@@ -76,7 +78,8 @@ def test_perses_regression(gufe_atom_mapping_matrix):
7678
assert matrix.shape == (8, 8)
7779

7880
# now run the openfe equivalent with the same ligand atom _mappings
79-
scorer = perses_scorers.default_perses_scorer
81+
with pytest.warns(DeprecationWarning, match="default_perses_scorer"):
82+
scorer = perses_scorers.default_perses_scorer
8083
scores = np.zeros_like(matrix)
8184
for (i, j), ligand_atom_mapping in gufe_atom_mapping_matrix.items():
8285
score = scorer(

0 commit comments

Comments
 (0)