Skip to content

Commit 47d6857

Browse files
Michael BarnettMichael Barnett
authored andcommitted
Slightly improved External controlled messages.
1 parent 5830cc6 commit 47d6857

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

commec/screeners/check_reg_path.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def unique_annotation_set(df) -> set[TaxonomyAnnotation]:
191191
reg_taxids = [] # Regulated Taxonomy IDS
192192
non_reg_taxids = [] # Non-regulated Taxonomy IDS.
193193
reg_species = [] # List of species
194+
non_reg_species = [] # List of species
194195
domains = [] # List of domains.
195196
match_ranges = [] # Ranges where hit matches query.
196197

@@ -251,6 +252,7 @@ def unique_annotation_set(df) -> set[TaxonomyAnnotation]:
251252

252253
# Collect unique species from both regulated and non-regulated - legacy logging
253254
reg_species.extend(regulated_for_region["species"])
255+
non_reg_species.extend(non_regulated_for_region["species"])
254256

255257
# JSON serialization requires int, not np.int64, hence the map()
256258
reg_taxids.extend(map(str, regulated_for_region["subject tax ids"]))
@@ -304,7 +306,7 @@ def unique_annotation_set(df) -> set[TaxonomyAnnotation]:
304306
if len(regulated_annotation_list) == 0:
305307
screen_status = ScreenStatus.PASS
306308
logger.debug("Only non-controlled entities due to control list compliance regional context")
307-
hit_description = (f"Externally controlled {domains_text}")
309+
hit_description = (f"Externally controlled{" " + domains_text if domains_text else ""}")
308310

309311
# Update the query level recommendation of this step.
310312
query_write.status.update_step_status(step, screen_status)
@@ -354,16 +356,17 @@ def unique_annotation_set(df) -> set[TaxonomyAnnotation]:
354356
non_reg_taxids.sort()
355357

356358
reg_species_text = ", ".join(reg_species)
359+
non_reg_species_text = ", ".join(non_reg_species)
357360
reg_taxids_text = ", ".join(reg_taxids)
358361
non_reg_taxids_text = ", ".join(non_reg_taxids)
359362
match_ranges_text = ", ".join(map(str,match_ranges))
360363

361-
alt_text = "only " if screen_status == ScreenStatus.FLAG else "both regulated and non-"
364+
alt_text = "only " if screen_status == ScreenStatus.FLAG else "both regulated and non-" if len(reg_taxids) > 0 else "externally "
362365
s = "" if len(reg_taxids) == 1 else "'s"
363366
ss = "" if len(non_reg_taxids) == 1 else "'s"
364367
log_message = (
365368
f"\t --> {screen_status} at bases ({match_ranges_text}) found in {alt_text}regulated {domains_text}.\n"
366-
f"\t (Regulated Species: {reg_species_text}.\n\t Regulated TaxID{s}: {reg_taxids_text}\n"
369+
f"\t (Regulated Species: {reg_species_text or non_reg_species_text}.\n\t Regulated TaxID{s}: {reg_taxids_text}\n"
367370
f"\t Non-Regulated TaxID{ss}: {non_reg_taxids_text})"
368371
)
369372
logger.debug(log_message)

0 commit comments

Comments
 (0)