Skip to content

Commit

Permalink
Add option to turn on/off warnings in BiolinkHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
amykglen committed Oct 6, 2024
1 parent 5b609be commit 4e35bdb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/ARAX/BiolinkHelper/biolink_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ def get_descendants(self, biolink_items: Union[str, List[str], Set[str]], includ
descendants.update(self.biolink_lookup_map["directions"][direction]["descendants"])
return list(descendants)

def get_canonical_predicates(self, predicates: Union[str, List[str], Set[str]]) -> List[str]:
def get_canonical_predicates(self, predicates: Union[str, List[str], Set[str]], print_warnings: bool = True) -> List[str]:
"""
Returns the canonical version of the input predicate(s). Accepts a single predicate or multiple predicates as
input and always returns the canonical predicate(s) in a list. Works with both proper and mixin predicates.
"""
input_predicate_set = self._convert_to_set(predicates)
valid_predicates = input_predicate_set.intersection(self.biolink_lookup_map["predicates"])
invalid_predicates = input_predicate_set.difference(valid_predicates)
if invalid_predicates:
if invalid_predicates and print_warnings:
eprint(f"WARNING: Provided predicate(s) {invalid_predicates} do not exist in Biolink {self.biolink_version}")
canonical_predicates = {self.biolink_lookup_map["predicates"][predicate]["canonical_predicate"]
for predicate in valid_predicates}
Expand Down

0 comments on commit 4e35bdb

Please sign in to comment.