Skip to content

Commit

Permalink
adding more array checks before assigning values
Browse files Browse the repository at this point in the history
  • Loading branch information
micheldumontier committed Aug 27, 2024
1 parent f85df16 commit 846ea20
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/trapi_predict_kit/trapi_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,25 @@ def resolve_trapi_query(reasoner_query, endpoints_list, infores: str = ""):
if "subject_label" in association:
node_dict[subject_id]["label"] = association["subject_label"]
else:
if subject_id in labels_dict and labels_dict[subject_id]:
# if subject_id in labels_dict and labels_dict[subject_id]:
if (
subject_id in labels_dict
and labels_dict[subject_id]
and "id" in labels_dict[subject_id]
and "label" in labels_dict[subject_id]["id"]
):
node_dict[subject_id]["label"] = labels_dict[subject_id]["id"]["label"]

if "object_label" in association:
node_dict[object_id]["label"] = association["object_label"]
else:
if object_id in labels_dict and labels_dict[object_id]:
# if object_id in labels_dict and labels_dict[object_id]:
if (
object_id in labels_dict
and labels_dict[object_id]
and "id" in labels_dict[object_id]
and "label" in labels_dict[object_id]["id"]
):
node_dict[object_id]["label"] = labels_dict[object_id]["id"]["label"]

# edge_association_type = 'biolink:ChemicalToDiseaseOrPhenotypicFeatureAssociation'
Expand Down

0 comments on commit 846ea20

Please sign in to comment.