Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,10 @@ Optional dependencies
Certain functionalities are only available if you also install other,
optional packages.

* **perses tools**: To use perses, you need to install perses and OpenEye,
and you need a valid OpenEye license. To install both packages, use::
* **perses tools**: To use the perses atom mapper and scorer, you need to install OpenEye, and you need a valid OpenEye license.
To install OpenEye, use::

$ mamba install -c openeye perses openeye-toolkits
$ mamba install -c openeye openeye-toolkits

Supported Hardware
------------------
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencies:
- openmmtools >=0.25.0
- packaging
- pandas
- perses>=0.10.3
- plugcli
- pint>=0.24.0
- pip
Expand Down
26 changes: 26 additions & 0 deletions news/perses-vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**Added:**

* <news item>

**Changed:**

* We have vendored the perses atom mapper and scorer.
This means the ``perses`` package is no longer needed to use the ``perses`` atom mapper and scorer.
However, OpenEye is still needed to use the ``perses`` atom mapper and scorer.
This is an internal packaging change and does not affect user scripts.

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
15 changes: 6 additions & 9 deletions openfe/setup/atom_mapping/perses_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@

"""

from openfe.utils import requires_package
from gufe.settings.typing import AngstromQuantity
from openff.units import unit, Quantity
from openff.units.openmm import to_openmm

from openff.utilities.utilities import requires_oe_module

from ...utils.silence_root_logging import silence_root_logging

try:
with silence_root_logging():
from perses.rjmc.atom_mapping import AtomMapper, InvalidMappingException
except ImportError:
pass # Don't throw error, will happen later
from openfe.vendor.perses._atom_mapping import _AtomMapper, _InvalidMappingException

from .ligandatommapper import LigandAtomMapper

Expand Down Expand Up @@ -49,7 +46,7 @@ def _from_dict(cls, dct: dict):
def _defaults(cls):
return {}

@requires_package("perses")
@requires_oe_module("oechem")
def __init__(
self,
allow_ring_breaking: bool = True,
Expand Down Expand Up @@ -81,7 +78,7 @@ def __init__(

def _mappings_generator(self, componentA, componentB):
# Construct Perses Mapper
_atom_mapper = AtomMapper(
_atom_mapper = _AtomMapper(
use_positions=self.use_positions,
coordinate_tolerance=to_openmm(self.coordinate_tolerance),
allow_ring_breaking=self.allow_ring_breaking,
Expand All @@ -92,7 +89,7 @@ def _mappings_generator(self, componentA, componentB):
_atom_mappings = _atom_mapper.get_all_mappings(
old_mol=componentA.to_openff(), new_mol=componentB.to_openff()
)
except InvalidMappingException:
except _InvalidMappingException:
return

# Catch empty mappings here
Expand Down
14 changes: 5 additions & 9 deletions openfe/setup/atom_mapping/perses_scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@

from typing import Callable

from openfe.utils import requires_package
from openff.utilities.utilities import requires_oe_module

from ...utils.silence_root_logging import silence_root_logging

try:
with silence_root_logging():
from perses.rjmc.atom_mapping import AtomMapper, AtomMapping
except ImportError:
pass # Don't throw error, will happen later
from openfe.vendor.perses._atom_mapping import _AtomMapper, _AtomMapping

from . import LigandAtomMapping

Expand All @@ -34,7 +30,7 @@ def _get_all_mapped_atoms_with(
return numMaxPossibleMappings


@requires_package("perses")
@requires_oe_module("oechem")
def default_perses_scorer(
mapping: LigandAtomMapping,
use_positions: bool = False,
Expand Down Expand Up @@ -67,8 +63,8 @@ def default_perses_scorer(
-------
float
"""
score = AtomMapper(use_positions=use_positions).score_mapping(
AtomMapping(
score = _AtomMapper(use_positions=use_positions).score_mapping(
_AtomMapping(
old_mol=mapping.componentA.to_openff(),
new_mol=mapping.componentB.to_openff(),
old_to_new_atom_map=mapping.componentA_to_componentB,
Expand Down
5 changes: 3 additions & 2 deletions openfe/tests/setup/atom_mapping/test_perses_scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from ....utils.silence_root_logging import silence_root_logging

from openfe.vendor.perses._atom_mapping import _AtomMapper, _AtomMapping

USING_OLD_OFF = False

Expand Down Expand Up @@ -67,13 +68,13 @@ def test_perses_regression(gufe_atom_mapping_matrix):
for x in gufe_atom_mapping_matrix.items():
(i, j), ligand_atom_mapping = x
# Build Perses Mapping:
perses_atom_mapping = AtomMapping(
perses_atom_mapping = _AtomMapping(
old_mol=ligand_atom_mapping.componentA.to_openff(),
new_mol=ligand_atom_mapping.componentB.to_openff(),
old_to_new_atom_map=ligand_atom_mapping.componentA_to_componentB,
)
# score Perses Mapping - Perses Style
matrix[i, j] = matrix[j, i] = AtomMapper().score_mapping(perses_atom_mapping)
matrix[i, j] = matrix[j, i] = _AtomMapper().score_mapping(perses_atom_mapping)

assert matrix.shape == (8, 8)

Expand Down
25 changes: 25 additions & 0 deletions openfe/vendor/perses/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The files in this folder are copied from [perses](https://github.com/choderalab/perses/blob/main/perses/rjmc/atom_mapping.py) commit: c716ba936fff992d596a342daebe4248597d287d
They have been modified and are licensed under the MIT license.
The orginal license is reproduced below:

MIT License

Copyright (c) 2015-2017 Chodera lab // Memorial Sloan Kettering Cancer Center

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file.
Loading
Loading