Skip to content

Commit

Permalink
Add LinkGraph to replace ObjectLink and LinkCollection (#252)
Browse files Browse the repository at this point in the history
* Update pyproject.toml

* Delete link_collection.py

* Delete object_link.py

* Create scoring_method.py

* Create score.py

* Create link_graph.py

* Update __init__.py

* Create test_score.py

* Create test_scoring_method.py

* Create test_link_graph.py

* update abc.py to use LinkGraph

* Update MetcalfScoring to use LinkGraph

- Use LinkGraph to replace ObjectLink and LinkCollection
- remove attribute `cutoff` and `standardised`. Now users have to pass them as parameters

* update NPLinker and other scoring methods to use LinkGraph

These updates are just to make sure code can import. Further refactoring is needed to ensure the correct output.

* Update test_nplinker_scoring.py
  • Loading branch information
CunliangGeng authored Jun 10, 2024
1 parent 3bed728 commit c7d2be8
Show file tree
Hide file tree
Showing 17 changed files with 545 additions and 448 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies = [
"httpx",
"jsonschema",
"numpy",
"networkx",
"pandas",
"pyteomics",
"rich",
Expand Down
1 change: 0 additions & 1 deletion src/nplinker/nplinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from .metabolomics import Spectrum
from .pickler import save_pickled_data
from .scoring.abc import ScoringBase
from .scoring.link_collection import LinkCollection
from .scoring.metcalf_scoring import MetcalfScoring
from .scoring.np_class_scoring import NPClassScoring
from .scoring.rosetta_scoring import RosettaScoring
Expand Down
13 changes: 10 additions & 3 deletions src/nplinker/scoring/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from .abc import ScoringBase
from .link_collection import LinkCollection
from .link_graph import LinkGraph
from .metcalf_scoring import MetcalfScoring
from .object_link import ObjectLink
from .score import Score
from .scoring_method import ScoringMethod


__all__ = ["LinkCollection", "MetcalfScoring", "ScoringBase", "ObjectLink"]
__all__ = [
"LinkGraph",
"MetcalfScoring",
"Score",
"ScoringBase",
"ScoringMethod",
]
16 changes: 10 additions & 6 deletions src/nplinker/scoring/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


if TYPE_CHECKING:
from nplinker import NPLinker
from . import LinkCollection
from nplinker.nplinker import NPLinker
from .link_graph import LinkGraph

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -36,15 +36,19 @@ def setup(cls, npl: NPLinker):
"""Setup class level attributes."""

@abstractmethod
def get_links(self, *objects, link_collection: LinkCollection) -> LinkCollection:
def get_links(
self,
*objects,
**parameters,
) -> LinkGraph:
"""Get links information for the given objects.
Args:
objects: A set of objects.
link_collection: The LinkCollection object.
objects: A list of objects to get links for.
parameters: The parameters used for scoring.
Returns:
The LinkCollection object.
The LinkGraph object.
"""

@abstractmethod
Expand Down
192 changes: 0 additions & 192 deletions src/nplinker/scoring/link_collection.py

This file was deleted.

Loading

0 comments on commit c7d2be8

Please sign in to comment.