Skip to content

Commit

Permalink
remove helper functions get_bgcs_from_gcfs and get_strains_from_bgcs
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Dec 14, 2023
1 parent 31672c9 commit ca7a658
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 43 deletions.
4 changes: 0 additions & 4 deletions src/nplinker/genomics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from .utils import add_bgc_to_gcf
from .utils import add_strain_to_bgc
from .utils import generate_mappings_genome_id_bgc_id
from .utils import get_bgcs_from_gcfs
from .utils import get_strains_from_bgcs


logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand All @@ -16,8 +14,6 @@
"BGC",
"GCF",
"generate_mappings_genome_id_bgc_id",
"get_bgcs_from_gcfs",
"get_strains_from_bgcs",
"add_bgc_to_gcf",
"add_strain_to_bgc",
]
19 changes: 0 additions & 19 deletions src/nplinker/genomics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,3 @@ def add_bgc_to_gcf(
f"{len(gcf_missing_bgc)} GCF objects have missing BGC objects."
)
return gcf_with_bgc, gcf_without_bgc, gcf_missing_bgc


def get_bgcs_from_gcfs(gcfs: list[GCF]) -> list[BGC]:
"""Get all BGC objects from given GCF objects."""
s = set()
for gcf in gcfs:
s |= gcf.bgcs
return list(s)


def get_strains_from_bgcs(bgcs: list[BGC]) -> StrainCollection:
"""Get all strain objects from given BGC objects."""
sc = StrainCollection()
for bgc in bgcs:
if bgc.strain is not None:
sc.add(bgc.strain)
else:
logger.warning("Strain is None for BGC %s", bgc.bgc_id)
return sc
20 changes: 0 additions & 20 deletions tests/genomics/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from nplinker.genomics import add_bgc_to_gcf
from nplinker.genomics import add_strain_to_bgc
from nplinker.genomics import generate_mappings_genome_id_bgc_id
from nplinker.genomics import get_bgcs_from_gcfs
from nplinker.genomics import get_strains_from_bgcs
from nplinker.globals import GENOME_BGC_MAPPINGS_FILENAME
from nplinker.strain import Strain
from nplinker.strain_collection import StrainCollection
Expand Down Expand Up @@ -156,21 +154,3 @@ def test_add_bgc_to_gcf_error(bgc_list, gcf_list_error):
with pytest.raises(KeyError) as e:
add_bgc_to_gcf(bgc_list, gcf_list_error)
assert "BGC id 'BGC_04' from GCF object '1' not found" in e.value.args[0]


def test_get_bgcs_from_gcfs(bgc_list, gcf_list):
"""Test get_bgcs_from_gcfs function."""
add_bgc_to_gcf(bgc_list, gcf_list)
bgcs = get_bgcs_from_gcfs(gcf_list)
assert isinstance(bgcs, list)
assert len(bgcs) == 3
for i in bgcs:
assert isinstance(i, BGC)


def test_get_strains_from_bgcs(strain_collection, bgc_list):
"""Test get_strains_from_bgcs function."""
add_strain_to_bgc(strain_collection, bgc_list)
strains = get_strains_from_bgcs(bgc_list)
assert isinstance(strains, StrainCollection)
assert strains == strain_collection

0 comments on commit ca7a658

Please sign in to comment.