From 1446738ff717840dec5ddb5ff4e1409bb0a45b5c Mon Sep 17 00:00:00 2001 From: Evan Morris Date: Thu, 24 Oct 2024 10:52:46 -0400 Subject: [PATCH] adding error checking for taxon normalization --- parsers/LitCoin/src/bagel/bagel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parsers/LitCoin/src/bagel/bagel.py b/parsers/LitCoin/src/bagel/bagel.py index 50c93dab..3d6d50c4 100644 --- a/parsers/LitCoin/src/bagel/bagel.py +++ b/parsers/LitCoin/src/bagel/bagel.py @@ -129,7 +129,10 @@ def augment_results(terms, nameres, taxes): resp = requests.get(f"{NODE_NORMALIZATION_URL}get_normalized_nodes?curie="+tax_id) if resp.status_code == 200: result = resp.json() - tax_name = result[tax_id]["id"]["label"] + try: + tax_name = result[tax_id]["id"]["label"] + except (TypeError, KeyError): + tax_name = f'Taxon name failed for {tax_id}' taxes[tax_id] = tax_name tax_name = taxes[tax_id] annotation["label"] = f"{annotation['label']} ({tax_name})"