Skip to content

Commit c96d7e1

Browse files
Improve error handling and default on disease matching
1 parent 3ccb9be commit c96d7e1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pori_python/ipr/ipr.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,14 @@ def get_kb_matches_sections(
627627

628628

629629
def get_kb_disease_matches(
630-
graphkb_conn: GraphKBConnection, kb_disease_match: str = 'cancer', verbose=True
630+
graphkb_conn: GraphKBConnection, kb_disease_match: str = None, verbose: bool = True
631631
) -> list[str]:
632+
633+
if not kb_disease_match:
634+
kb_disease_match = 'cancer'
635+
if verbose:
636+
logger.warning(f"No disease provided; will use '{kb_disease_match}'")
637+
632638
if verbose:
633639
logger.info(f"Matching disease ({kb_disease_match}) to graphkb")
634640

pori_python/ipr/main.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,8 @@ def ipr_report(
384384
kb_disease_match: str = content["kbDiseaseMatch"]
385385

386386
# Matching disease RIDs from GraphKB using term tree
387-
disease_matches: list[str] = []
388-
try:
389-
disease_matches = get_kb_disease_matches(graphkb_conn, kb_disease_match)
390-
except ValueError as err:
391-
# 2nd try using deafult disease term.
392-
# Will raise uncatched error if no match
393-
disease_matches = get_kb_disease_matches(graphkb_conn)
387+
# (Will raise uncatched error if no match)
388+
disease_matches: list[str] = get_kb_disease_matches(graphkb_conn, kb_disease_match)
394389

395390
# GKB MATCHING
396391
gkb_matches: List[Hashabledict] = []

0 commit comments

Comments
 (0)