Skip to content

Commit

Permalink
refactor MetcalfScoring methods (#254)
Browse files Browse the repository at this point in the history
* update abc.py to change `npl` to class attribute

It might lead to inconsistent `npl` if both `__init__` and `setup` take `npl` as parameter.

* remove `calc_score` method

This method is just a wrapper on `_calc_raw_score` and `_calc_mean_std`.
Better to move its code to `setup` method.

* update `setup` to use `cls.npl`

-  use `cls.npl`
- remove setup code from cache

* rename objtype to type

* change the format of raw score data frame

* Update `get_links` to use new format of dataframe

* Update metcalf_scoring.py

* change LINK_TYPES to enum LinkType

Update metcalf_scoring.py

* update `_get_links`

* add type variable ObjectType

* change `obj_type` from a string value to actual data type

* remove unused function

* clean `get_links`

* update docstrings for class attributes

* use hashable object itself as index or column of dataframe

E.g. use `GCF` instead of `GCF.id` as the index or column of a dataframe. This will skip the steps to look up actual object with a given id.

* update the code for calculating standardised score

* update unit tests

* Apply suggestions from code review

Co-authored-by: Giulia Crocioni <55382553+gcroci2@users.noreply.github.com>

---------

Co-authored-by: Giulia Crocioni <55382553+gcroci2@users.noreply.github.com>
  • Loading branch information
CunliangGeng and gcroci2 authored Jun 14, 2024
1 parent fc4fb50 commit 10e9d87
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 725 deletions.
9 changes: 1 addition & 8 deletions src/nplinker/scoring/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ class ScoringBase(ABC):
"""

name: str = "ScoringBase"

def __init__(self, npl: NPLinker):
"""Initialize the scoring method.
Args:
npl: The NPLinker object.
"""
self.npl = npl
npl: NPLinker | None = None

@classmethod
@abstractmethod
Expand Down
Loading

0 comments on commit 10e9d87

Please sign in to comment.