Skip to content

Commit

Permalink
refactor NPLinker class (#256)
Browse files Browse the repository at this point in the history
* remove unused property `metadata`

* refactor private data containers and relevant methods

* remove legacy code for saving data

* change the variable of default database folder to package level

* update config related code

* uniform the names of scoring methods

* refactor `NPLinker.get_links` method

- remove unused method `scoring_method`
- refactor the method `get_links`

* Delete test_nplinker_scoring.py

* reorder methods and properties of NPLinker class

* fix returned value type

* update integration tests

- simplify the `conftest.py`
- remove unused functions
- add tests for `get_link`

* fix mypy errors
  • Loading branch information
CunliangGeng authored Jun 14, 2024
1 parent 06fe1f9 commit fc9ddec
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 461 deletions.
8 changes: 7 additions & 1 deletion src/nplinker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from pathlib import Path


logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand All @@ -8,6 +9,11 @@
__version__ = "2.0.0-alpha.1"


# The path to the NPLinker application database directory
NPLINKER_APP_DATA_DIR = Path(__file__).parent / "data"
del Path


def setup_logging(level: str = "INFO", file: str = "", use_console: bool = True) -> None:
"""Setup logging configuration for the ancestor logger "nplinker".
Expand All @@ -22,7 +28,7 @@ def setup_logging(level: str = "INFO", file: str = "", use_console: bool = True)
from rich.console import Console
from rich.logging import RichHandler

# Get the acncestor logger "nplinker"
# Get the ancestor logger "nplinker"
logger = logging.getLogger(__name__)
logger.setLevel(level)

Expand Down
9 changes: 4 additions & 5 deletions src/nplinker/loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import os
from importlib.resources import files
from deprecated import deprecated
from dynaconf import Dynaconf
from nplinker import NPLINKER_APP_DATA_DIR
from nplinker import defaults
from nplinker.genomics.antismash import AntismashBGCLoader
from nplinker.genomics.bigscape import BigscapeGCFLoader
Expand All @@ -23,8 +23,6 @@

logger = logging.getLogger(__name__)

NPLINKER_APP_DATA_DIR = files("nplinker").joinpath("data")


class DatasetLoader:
"""Class to load all data.
Expand Down Expand Up @@ -228,9 +226,10 @@ def _load_class_info(self):
True if everything completes
"""
# load Class_matches with mibig info from data
mibig_class_file = NPLINKER_APP_DATA_DIR.joinpath(
"MIBiG2.0_compounds_with_AS_BGC_CF_NPC_classes.txt"
mibig_class_file = (
NPLINKER_APP_DATA_DIR / "MIBiG2.0_compounds_with_AS_BGC_CF_NPC_classes.txt"
)

self.class_matches = ClassMatches(mibig_class_file) # noqa

# run canopus if canopus_dir does not exist
Expand Down
Loading

0 comments on commit fc9ddec

Please sign in to comment.