From ca7a658063d6463d6f4710f58f4ff66ed9714908 Mon Sep 17 00:00:00 2001 From: Cunliang Geng Date: Mon, 11 Dec 2023 17:29:42 +0100 Subject: [PATCH] remove helper functions `get_bgcs_from_gcfs` and `get_strains_from_bgcs` --- src/nplinker/genomics/__init__.py | 4 ---- src/nplinker/genomics/utils.py | 19 ------------------- tests/genomics/test_utils.py | 20 -------------------- 3 files changed, 43 deletions(-) diff --git a/src/nplinker/genomics/__init__.py b/src/nplinker/genomics/__init__.py index d90272b0..119bd8f2 100644 --- a/src/nplinker/genomics/__init__.py +++ b/src/nplinker/genomics/__init__.py @@ -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()) @@ -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", ] diff --git a/src/nplinker/genomics/utils.py b/src/nplinker/genomics/utils.py index b640e611..5187bca8 100644 --- a/src/nplinker/genomics/utils.py +++ b/src/nplinker/genomics/utils.py @@ -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 diff --git a/tests/genomics/test_utils.py b/tests/genomics/test_utils.py index 15f07a52..96c73add 100644 --- a/tests/genomics/test_utils.py +++ b/tests/genomics/test_utils.py @@ -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 @@ -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