Skip to content

Commit

Permalink
change return value to a list for _parse_gcf method
Browse files Browse the repository at this point in the history
This change will simplify the `__init__` method.
  • Loading branch information
CunliangGeng committed Oct 25, 2023
1 parent ae73971 commit 6dd2513
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/nplinker/genomics/bigscape/bigscape_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def __init__(self, cluster_file: str | PathLike, /) -> None:
cluster_file(str): path to the BiG-SCAPE cluster file.
"""
self.cluster_file = str(cluster_file)
self._gcf_dict = self._parse_gcf(self.cluster_file)
self._gcf_list = list(self._gcf_dict.values())
self._gcf_list = self._parse_gcf(self.cluster_file)

def get_gcfs(self, keep_mibig_only=False) -> list[GCF]:
"""Get all GCF objects.
Expand All @@ -40,9 +39,9 @@ def get_gcfs(self, keep_mibig_only=False) -> list[GCF]:
return self._gcf_list

@staticmethod
def _parse_gcf(cluster_file: str) -> dict[str, GCF]:
def _parse_gcf(cluster_file: str) -> list[GCF]:
"""Parse BiG-SCAPE cluster file to return GCF objects."""
gcf_dict = {}
gcf_dict: dict[str, GCF] = {}
with open(cluster_file, "rt", encoding="utf-8") as f:
reader = csv.reader(f, delimiter='\t')
next(reader) # skip headers
Expand All @@ -51,7 +50,7 @@ def _parse_gcf(cluster_file: str) -> dict[str, GCF]:
if family_id not in gcf_dict:
gcf_dict[family_id] = GCF(family_id)
gcf_dict[family_id].bgc_ids.add(bgc_id)
return gcf_dict
return list(gcf_dict.values())


# register as virtual class to prevent metaclass conflicts
Expand Down

0 comments on commit 6dd2513

Please sign in to comment.