Skip to content

Commit

Permalink
clarify logging and function docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nlouwen committed Nov 1, 2024
1 parent ca764cc commit 36820d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions big_scape/run_bigscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def signal_handler(sig, frame):
else:
all_bgc_records = bs_files.get_all_bgc_records(run, gbks)

logging.info("Continuing with %s BGC records", len(all_bgc_records))

# INCLUDE/EXCLUDE CATEGORIES
if run["include_categories"] or run["exclude_categories"]:
all_bgc_records = category_filter(run, all_bgc_records)
Expand Down Expand Up @@ -187,12 +189,10 @@ def signal_handler(sig, frame):

# DOMAIN INCLUSION LIST FILTER
if run["domain_includelist_all"] or run["domain_includelist_any"]:
logging.info("Filtering records by domain_includelist")

all_bgc_records = domain_includelist_filter(run, all_bgc_records)

logging.info(
"Continuing with %i filtered records",
"Continuing with %i BGC records after domain_includelist filtering",
len(all_bgc_records),
)

Expand Down
18 changes: 9 additions & 9 deletions big_scape/utility/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ def domain_includelist_filter(run: dict, all_bgc_records: list[bs_gbk.BGCRecord]
def generic_category_class_filter(
class_categ: set[str], include: set[str], exclude: set[str]
) -> bool:
"""Generic function for both class and category based filtering of records
"""Generic function for both class and category based filtering of a single record
exclude class/category is checked first, removing any records that contain any of
these classes/categories. Then, include class/category is checked, keeping only any
exclude class/category is checked first, failing any records that contain any of
these classes/categories. Then, include class/category is checked, passing only any
records that contain any of these classes/categories.
Args:
class_categ (set[str]): set of classes or categories
class_categ (set[str]): set of classes or categories present in a single record
include (set[str]): set of classes or categories to include
exclude (set[str]): set of classes or categories to exclude
Returns:
bool: false if filtered out, true if kept
bool: True if the current record passes filters, False if it is filtered out
"""
if exclude:
if class_categ & exclude:
Expand Down Expand Up @@ -97,13 +97,13 @@ def category_filter(

if len(filtered_bgc_records) == 0:
logging.error(
"No GBKs remain after include/exclude categories filtering",
"No BGC records remain after include/exclude categories filtering",
)
raise RuntimeError()

if orig_size != len(filtered_bgc_records):
logging.info(
"%s GBKs remain after include/exclude categories filtering",
"Continuing with %s BGC records after include/exclude categories filtering",
len(filtered_bgc_records),
)
return filtered_bgc_records
Expand Down Expand Up @@ -136,13 +136,13 @@ def class_filter(

if len(filtered_bgc_records) == 0:
logging.error(
"No GBKs remain after include/exclude classes filtering",
"No BGC records remain after include/exclude classes filtering",
)
raise RuntimeError()

if orig_size != len(filtered_bgc_records):
logging.info(
"%s GBKs remain after include/exclude classes filtering",
"Continuing with %s BGC records after include/exclude classes filtering",
len(filtered_bgc_records),
)
return filtered_bgc_records

0 comments on commit 36820d0

Please sign in to comment.