Skip to content

Commit

Permalink
use default output path for metcalf scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Apr 17, 2024
1 parent 0d11925 commit 745733a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/nplinker/scoring/metcalf_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import TYPE_CHECKING
import numpy as np
import pandas as pd
from nplinker.defaults import OUTPUT_DEFAULT_PATH
from nplinker.genomics import GCF
from nplinker.logconfig import LogConfig
from nplinker.metabolomics import MolecularFamily
Expand Down Expand Up @@ -31,11 +32,13 @@ class MetcalfScoring(ScoringMethod):
DATALINKS: The DataLinks object to use for scoring.
LINKFINDER: The LinkFinder object to use for scoring.
NAME: The name of the scoring method. This is set to 'metcalf'.
CACHE: The name of the cache file to use for storing the MetcalfScoring.
"""

DATALINKS = None
LINKFINDER = None
NAME = "metcalf"
CACHE = "cache_metcalf_scoring.pckl"

def __init__(self, npl: NPLinker) -> None:
"""Create a MetcalfScoring object.
Expand Down Expand Up @@ -69,9 +72,8 @@ def setup(npl: NPLinker):
)
)

cache_dir = os.path.join(npl.root_dir, "metcalf")
cache_file = os.path.join(cache_dir, "metcalf_scores.pckl")
os.makedirs(cache_dir, exist_ok=True)
OUTPUT_DEFAULT_PATH.mkdir(exist_ok=True)
cache_file = OUTPUT_DEFAULT_PATH / MetcalfScoring.CACHE

# the metcalf preprocessing can take a long time for large datasets, so it's
# better to cache as the data won't change unless the number of objects does
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_nplinker_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def npl() -> NPLinker:
npl.load_data()
# remove cached score results before running tests
root_dir = Path(npl.root_dir)
score_cache = root_dir / "metcalf" / "metcalf_scores.pckl"
score_cache = root_dir / "output" / "cache_metcalf_scoring.pckl"
score_cache.unlink(missing_ok=True)
return npl

Expand Down

0 comments on commit 745733a

Please sign in to comment.