-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'vite-app' of github.com:SmartAPI/smartAPI into vite-app
- Loading branch information
Showing
3 changed files
with
191 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Union, List | ||
import bmt | ||
|
||
# Initialize the Biolink Model Toolkit instance globally if it's used frequently | ||
# or pass it as a parameter to functions that require it. | ||
toolkit = bmt.Toolkit() | ||
|
||
def get_expanded_values(value: Union[str, List[str]], toolkit_instance=toolkit) -> List[str]: | ||
"""Return expanded value list for a given Biolink class name.""" | ||
if isinstance(value, str): | ||
value = [value] | ||
_out = [] | ||
for v in value: | ||
try: | ||
v = toolkit_instance.get_descendants(v, reflexive=True, formatted=True) | ||
v = [x.split(":")[-1] for x in v] # Remove 'biolink:' prefix | ||
except ValueError: | ||
v = [v] | ||
_out.extend(v) | ||
return _out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters