Skip to content

Commit

Permalink
remove function filter_mibig_only_gcf
Browse files Browse the repository at this point in the history
This function is needed anymore. GCF loader already has the functionality to filter mibig only GCF during loading.
  • Loading branch information
CunliangGeng committed Nov 20, 2023
1 parent 3eadaa5 commit 3d8330a
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 21 deletions.
2 changes: 0 additions & 2 deletions src/nplinker/genomics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .abc import BGCLoaderBase
from .bgc import BGC
from .gcf import GCF
from .genomics import filter_mibig_only_gcf
from .genomics import generate_mappings_genome_id_bgc_id
from .genomics import get_bgcs_from_gcfs
from .genomics import get_strains_from_bgcs
Expand All @@ -16,7 +15,6 @@
"BGCLoaderBase",
"BGC",
"GCF",
"filter_mibig_only_gcf",
"generate_mappings_genome_id_bgc_id",
"get_bgcs_from_gcfs",
"get_strains_from_bgcs",
Expand Down
9 changes: 0 additions & 9 deletions src/nplinker/genomics/genomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,6 @@ def map_bgc_to_gcf(bgcs: list[BGC], gcfs: list[GCF]):
gcf.add_bgc(bgc)


def filter_mibig_only_gcf(gcfs: list[GCF]) -> list[GCF]:
"""Filter out GCFs that contain only MIBiG BGC objects.
This method returns a new list of GCFs that have at least one non-MIBiG
BGC object as its child.
"""
return [gcf for gcf in gcfs if gcf.has_mibig_only() is False]


def get_bgcs_from_gcfs(gcfs: list[GCF]) -> list[BGC]:
"""Get all BGC objects from given GCF objects."""
s = set()
Expand Down
3 changes: 1 addition & 2 deletions src/nplinker/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from nplinker.genomics import generate_mappings_genome_id_bgc_id
from nplinker.genomics.antismash import AntismashBGCLoader
from nplinker.genomics.bigscape import BigscapeGCFLoader
from nplinker.genomics.genomics import filter_mibig_only_gcf
from nplinker.genomics.genomics import get_bgcs_from_gcfs
from nplinker.genomics.genomics import get_strains_from_bgcs
from nplinker.genomics.genomics import map_bgc_to_gcf
Expand Down Expand Up @@ -453,7 +452,7 @@ def _load_genomics(self):
map_bgc_to_gcf(raw_bgcs, raw_gcfs)

# Step 5: get clean GCF objects, BGC objects and Strain objects
self.gcfs = filter_mibig_only_gcf(raw_gcfs)
self.gcfs = raw_gcfs
self.bgcs = get_bgcs_from_gcfs(self.gcfs)
self.strains = get_strains_from_bgcs(self.bgcs)

Expand Down
8 changes: 0 additions & 8 deletions tests/genomics/test_genomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest
from nplinker.genomics import BGC
from nplinker.genomics import GCF
from nplinker.genomics import filter_mibig_only_gcf
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
Expand Down Expand Up @@ -149,13 +148,6 @@ def test_map_bgc_to_gcf_error(bgc_list, gcf_list_error):
assert "BGC id 'BGC_04' from GCF object '1' not found" in e.value.args[0]


def test_filter_mibig_only_gcf(bgc_list, gcf_list):
map_bgc_to_gcf(bgc_list, gcf_list)
gcfs = filter_mibig_only_gcf(gcf_list)
assert len(gcfs) == 1
assert gcfs[0].gcf_id == "2"


def test_get_bgcs_from_gcfs(bgc_list, gcf_list):
map_bgc_to_gcf(bgc_list, gcf_list)
bgcs = get_bgcs_from_gcfs(gcf_list)
Expand Down

0 comments on commit 3d8330a

Please sign in to comment.