diff --git a/src/wags_tails/__init__.py b/src/wags_tails/__init__.py index db8b3fa..0ccf73b 100644 --- a/src/wags_tails/__init__.py +++ b/src/wags_tails/__init__.py @@ -1,4 +1,5 @@ """Data acquisition tools for Wagnerds.""" +from .base_source import DataSource from .chembl import ChemblData from .chemidplus import ChemIDplusData from .custom import CustomData @@ -7,9 +8,11 @@ from .guide_to_pharmacology import GToPLigandData from .hemonc import HemOncData from .mondo import MondoData +from .ncit import NcitData from .rxnorm import RxNormData __all__ = [ + "DataSource", "ChemblData", "ChemIDplusData", "CustomData", @@ -18,5 +21,6 @@ "GToPLigandData", "HemOncData", "MondoData", + "NcitData", "RxNormData", ] diff --git a/src/wags_tails/custom.py b/src/wags_tails/custom.py index fdf47ca..895f158 100644 --- a/src/wags_tails/custom.py +++ b/src/wags_tails/custom.py @@ -24,6 +24,7 @@ def __init__( latest_version_cb: Callable[[], str], download_cb: Callable[[Path, str], None], data_dir: Optional[Path] = None, + file_name: Optional[str] = None, silent: bool = False, ) -> None: """Set common class parameters. @@ -41,12 +42,17 @@ def __init__( $WAGS_TAILS_DIR, or within a "wags_tails" subdirectory under environment variables $XDG_DATA_HOME or $XDG_DATA_DIRS, or finally, at ``~/.local/share/`` + :param file_name: name to use for base of filename if given :param silent: if True, don't print any info/updates to console """ self._src_name = src_name self._file_suffix = file_suffix self._get_latest_version = latest_version_cb self._download_data = download_cb + if file_name: + self._file_name = file_name + else: + self._file_name = src_name super().__init__(data_dir, silent) def get_latest( @@ -65,15 +71,15 @@ def get_latest( if from_local: file_path = self._get_latest_local_file( - f"{self._src_name}_*.{self._file_suffix}" + f"{self._file_name}_*.{self._file_suffix}" ) return file_path, parse_file_version( - file_path, f"{self._src_name}_(\\d+).{self._file_suffix}" + file_path, f"{self._file_name}_(\\d+).{self._file_suffix}" ) latest_version = self._get_latest_version() latest_file = ( - self._data_dir / f"{self._src_name}_{latest_version}.{self._file_suffix}" + self._data_dir / f"{self._file_name}_{latest_version}.{self._file_suffix}" ) if (not force_refresh) and latest_file.exists(): _logger.debug(