Skip to content

Commit

Permalink
update logging warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nlouwen committed Nov 18, 2024
1 parent 5e5fc0a commit a098509
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion big_scape/file_input/load_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def remove_duplicate_gbk(gbks: list[GBK]) -> list[GBK]:
unique_gbks = set()
for gbk in gbks:
if gbk in unique_gbks:
logging.info("Skipping duplicate %s", gbk)
logging.info("Skipping duplicate %s", gbk.path)
continue
unique_gbks.add(gbk)

Expand Down
22 changes: 22 additions & 0 deletions big_scape/genbank/bgc_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,20 @@ def get_sub_records(
Returns:
list[BGCRecord]: list of records of the specified type
"""
err_path = region.parent_gbk.path if region.parent_gbk else ""

if region is None:
return []

if record_type == bs_enums.genbank.RECORD_TYPE.REGION:
return [region]

if region.cand_clusters is None:
logging.warning(
"%s: No %s records found, using region instead.",
err_path,
record_type.value,
)
return [region]

cand_clusters = [
Expand All @@ -419,6 +426,11 @@ def get_sub_records(
]

if len(cand_clusters) == 0:
logging.warning(
"%s: No %s records found, using region instead.",
err_path,
record_type.value,
)
return [region]

# TODO: check if properly implemented, or at all
Expand All @@ -445,6 +457,11 @@ def get_sub_records(
proto_cluster_numbers.append(proto_cluster.number)

if len(proto_clusters) == 0:
logging.warning(
"%s: No %s records found, using cand_cluster instead.",
err_path,
record_type.value,
)
return cand_clusters

if record_type == bs_enums.genbank.RECORD_TYPE.PROTO_CLUSTER:
Expand All @@ -461,6 +478,11 @@ def get_sub_records(
proto_core_numbers.append(proto_core.number)

if len(proto_cores) == 0:
logging.warning(
"%s: No %s records found, using protocluster instead.",
err_path,
record_type.value,
)
return proto_clusters

return proto_cores

0 comments on commit a098509

Please sign in to comment.