Skip to content

Commit

Permalink
change datas to data
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Jun 14, 2024
1 parent c5c0e60 commit 7e1180f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/nplinker/genomics/mibig/mibig_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, data_dir: str):
"""
self.data_dir = data_dir
self._file_dict = self.parse_data_dir(self.data_dir)
self._metadata_dict = self._parse_metadatas()
self._metadata_dict = self._parse_metadata()
self._bgcs = self._parse_bgcs()

def get_files(self) -> dict[str, str]:
Expand Down Expand Up @@ -58,15 +58,15 @@ def parse_data_dir(data_dir: str) -> dict[str, str]:
file_dict[fname] = file
return file_dict

def get_metadatas(self) -> dict[str, MibigMetadata]:
def get_metadata(self) -> dict[str, MibigMetadata]:
"""Get MibigMetadata objects.
Returns:
The key is BGC accession (file name) and the value is MibigMetadata object
"""
return self._metadata_dict

def _parse_metadatas(self) -> dict[str, MibigMetadata]:
def _parse_metadata(self) -> dict[str, MibigMetadata]:
"""Parse all metadata files and return MibigMetadata objects.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/genomics/test_mibig_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from nplinker.genomics import mibig


class TestDownloadAndExtractMibigMetadatas:
class TestDownloadAndExtractMibigMetadata:
def test_default(self, tmp_path):
download_path = tmp_path / "download"
extract_path = tmp_path / "metadata"
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/genomics/test_mibig_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def test_parse_data_dir(self, data_dir):
assert isinstance(files["BGC0000001"], str)
assert os.path.exists(files["BGC0000001"])

def test_get_metadatas(self, loader):
metadatas = loader.get_metadatas()
assert isinstance(metadatas, dict)
assert len(metadatas) == 2502 # MIBiG v3.1 has 2502 BGCs
assert "BGC0000001" in metadatas
assert "BGC0000246" not in metadatas
assert isinstance(metadatas["BGC0000001"], MibigMetadata)
def test_get_metadata(self, loader):
metadata = loader.get_metadata()
assert isinstance(metadata, dict)
assert len(metadata) == 2502 # MIBiG v3.1 has 2502 BGCs
assert "BGC0000001" in metadata
assert "BGC0000246" not in metadata
assert isinstance(metadata["BGC0000001"], MibigMetadata)

def test_get_bgcs(self, loader):
bgcs = loader.get_bgcs()
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_find_delimiter(filename, expected):


BGC_GBK_URL = "https://mibig.secondarymetabolites.org/repository/BGC0000001/BGC0000001.gbk"
MIBIG_METADATAS_URL = "https://dl.secondarymetabolites.org/mibig/mibig_json_3.1.tar.gz"
MIBIG_METADATA_URL = "https://dl.secondarymetabolites.org/mibig/mibig_json_3.1.tar.gz"
ROOT = Path(__file__).parent


Expand Down Expand Up @@ -47,7 +47,7 @@ class TestExtractArchive:
@pytest.fixture
def archive(self):
temppath = mkdtemp()
utils.download_url(MIBIG_METADATAS_URL, temppath)
utils.download_url(MIBIG_METADATA_URL, temppath)
archive = Path(temppath) / "mibig_json_3.1.tar.gz"
yield archive

Expand Down Expand Up @@ -82,7 +82,7 @@ def temppath2(self):
rmtree(temppath)

def test_defaults(self, temppath1):
utils.download_and_extract_archive(url=MIBIG_METADATAS_URL, download_root=temppath1)
utils.download_and_extract_archive(url=MIBIG_METADATA_URL, download_root=temppath1)

fdownload = Path(temppath1) / "mibig_json_3.1.tar.gz"
fextract = Path(temppath1) / "mibig_json_3.1"
Expand All @@ -92,7 +92,7 @@ def test_defaults(self, temppath1):

def test_optional_args(self, temppath1, temppath2):
utils.download_and_extract_archive(
url=MIBIG_METADATAS_URL,
url=MIBIG_METADATA_URL,
download_root=temppath1,
extract_root=temppath2,
filename="example.tar.gz",
Expand All @@ -108,7 +108,7 @@ def test_optional_args(self, temppath1, temppath2):

def test_arg_remove_finished(self, temppath1):
utils.download_and_extract_archive(
url=MIBIG_METADATAS_URL, download_root=temppath1, remove_finished=True
url=MIBIG_METADATA_URL, download_root=temppath1, remove_finished=True
)

fdownload = Path(temppath1) / "mibig_json_3.1.tar.gz"
Expand Down

0 comments on commit 7e1180f

Please sign in to comment.