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

Enable PersesAtomMapper #929

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
26 changes: 25 additions & 1 deletion openfe/setup/atom_mapping/perses_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,36 @@
allow_ring_breaking: bool
preserve_chirality: bool
use_positions: bool
coordinate_tolerance: unit.Quantity

def _to_dict(self) -> dict:
jthorton marked this conversation as resolved.
Show resolved Hide resolved
# strip units but record values
return {

Check warning on line 32 in openfe/setup/atom_mapping/perses_mapper.py

View check run for this annotation

Codecov / codecov/patch

openfe/setup/atom_mapping/perses_mapper.py#L32

Added line #L32 was not covered by tests
"allow_ring_breaking": self.allow_ring_breaking,
"preserve_chirality": self.preserve_chirality,
"use_positions": self.use_positions,
"coordinate_tolerance": self.coordinate_tolerance.value_in_unit(
jthorton marked this conversation as resolved.
Show resolved Hide resolved
unit.angstrom
),
"_tolerance_unit": "angstrom"
}

@classmethod
def _from_dict(cls, dct: dict):
# attach units again
tolerence_unit = dct.pop("_tolerance_unit")
dct["coordinate_tolerance"] *= getattr(unit, tolerence_unit)
return cls(**dct)

Check warning on line 47 in openfe/setup/atom_mapping/perses_mapper.py

View check run for this annotation

Codecov / codecov/patch

openfe/setup/atom_mapping/perses_mapper.py#L45-L47

Added lines #L45 - L47 were not covered by tests

@classmethod
def _defaults(cls):
return {}

Check warning on line 51 in openfe/setup/atom_mapping/perses_mapper.py

View check run for this annotation

Codecov / codecov/patch

openfe/setup/atom_mapping/perses_mapper.py#L51

Added line #L51 was not covered by tests

@requires_package("perses")
def __init__(self, allow_ring_breaking: bool = True,
preserve_chirality: bool = True,
use_positions: bool = True,
coordinate_tolerance: float = 0.25 * unit.angstrom):
coordinate_tolerance: unit.Quantity = 0.25 * unit.angstrom):
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
"""
Suggest atom mappings with the Perses atom mapper.

Expand Down
10 changes: 7 additions & 3 deletions openfe/tests/setup/atom_mapping/test_perses_atommapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
USING_NEW_OFF = True # by default we are now


@pytest.mark.xfail(USING_NEW_OFF, reason="Perses #1108")
def test_simple(atom_mapping_basic_test_files):
# basic sanity check on the LigandAtomMapper
mol1 = atom_mapping_basic_test_files['methylcyclohexane']
Expand All @@ -25,7 +24,6 @@
assert len(mapping.componentA_to_componentB) == 4


@pytest.mark.xfail(USING_NEW_OFF, reason="Perses #1108")
def test_generator_length(atom_mapping_basic_test_files):
# check that we get one mapping back from Lomap LigandAtomMapper then the
# generator stops correctly
Expand All @@ -41,7 +39,6 @@
next(mapping_gen)


@pytest.mark.xfail(USING_NEW_OFF, reason="Perses #1108")
def test_empty_atommappings(mol_pair_to_shock_perses_mapper):
mol1, mol2 = mol_pair_to_shock_perses_mapper
mapper = PersesAtomMapper()
Expand All @@ -53,3 +50,10 @@

with pytest.raises(StopIteration):
next(mapping_gen)


def test_dict_round_trip():

Check warning on line 55 in openfe/tests/setup/atom_mapping/test_perses_atommapper.py

View check run for this annotation

Codecov / codecov/patch

openfe/tests/setup/atom_mapping/test_perses_atommapper.py#L55

Added line #L55 was not covered by tests
# use some none defaults
mapper1 = PersesAtomMapper(allow_ring_breaking=False, preserve_chirality=False)
mapper2 = PersesAtomMapper.from_dict(mapper1.to_dict())
assert mapper2.to_dict() == mapper1.to_dict()

Check warning on line 59 in openfe/tests/setup/atom_mapping/test_perses_atommapper.py

View check run for this annotation

Codecov / codecov/patch

openfe/tests/setup/atom_mapping/test_perses_atommapper.py#L57-L59

Added lines #L57 - L59 were not covered by tests
Loading