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

Adding a generic atom mapping scorer #306

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
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
42 changes: 42 additions & 0 deletions gufe/mapping/atom_mapping_scorer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This code is part of kartograf and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/gufe

import abc

Check warning on line 4 in gufe/mapping/atom_mapping_scorer.py

View check run for this annotation

Codecov / codecov/patch

gufe/mapping/atom_mapping_scorer.py#L4

Added line #L4 was not covered by tests

from . import AtomMapping

Check warning on line 6 in gufe/mapping/atom_mapping_scorer.py

View check run for this annotation

Codecov / codecov/patch

gufe/mapping/atom_mapping_scorer.py#L6

Added line #L6 was not covered by tests


class AtomMappingScorer(abc.ABC):

Check warning on line 9 in gufe/mapping/atom_mapping_scorer.py

View check run for this annotation

Codecov / codecov/patch

gufe/mapping/atom_mapping_scorer.py#L9

Added line #L9 was not covered by tests
"""A generic class for scoring Atom mappings.
this class can be used for example to build graph algorithm based networks.

Implementations of this class can require an arbitrary and non-standardised
number of input arguments to create.

Implementations of this class provide the :meth:`.get_score` method

"""

def __call__(self, mapping: AtomMapping, *args, **kwargs) -> float:
return self.get_score(mapping)

Check warning on line 21 in gufe/mapping/atom_mapping_scorer.py

View check run for this annotation

Codecov / codecov/patch

gufe/mapping/atom_mapping_scorer.py#L20-L21

Added lines #L20 - L21 were not covered by tests

@abc.abstractmethod
def get_score(self, mapping: AtomMapping, *args, **kwargs) -> float:

Check warning on line 24 in gufe/mapping/atom_mapping_scorer.py

View check run for this annotation

Codecov / codecov/patch

gufe/mapping/atom_mapping_scorer.py#L23-L24

Added lines #L23 - L24 were not covered by tests
RiesBen marked this conversation as resolved.
Show resolved Hide resolved
""" calculate the score for an :class:`.AtomMapping`
the scoring function returns a value between 0 and 1.
a value close to 1.0 indicates a small distance, a score close to zero indicates a large cost/error.

Parameters
----------
mapping: AtomMapping
the mapping to be scored
args
kwargs

Returns
-------
float
a value between [0,1] where one is a very bad score and 0 a very good one.
RiesBen marked this conversation as resolved.
Show resolved Hide resolved

"""
pass

Check warning on line 42 in gufe/mapping/atom_mapping_scorer.py

View check run for this annotation

Codecov / codecov/patch

gufe/mapping/atom_mapping_scorer.py#L42

Added line #L42 was not covered by tests