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

refactor NPLinker class #256

Merged
merged 12 commits into from
Jun 14, 2024
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
gcroci2 marked this conversation as resolved.
Show resolved Hide resolved


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
Loading