Standalone BiolinkHelper module extracted from RTX
Project description
BiolinkHelper
This module provides a few methods for easy access to Biolink Model info. It uses a local (cached) copy of the Biolink Model, transformed for easy lookups. Its data source is the Biolink Model YAML file.
How to use
Start by creating an instance of the helper:
from biolink_helper import BiolinkHelper
biolink_helper = BiolinkHelper()
It will automatically use the Biolink Model version that ARAX is currently on (as specified in the ARAX OpenAPI YAML file). If you want to use a different version, you can specify it via the optional biolink_version parameter (not recommended).
Examples of ways to get ancestors:
biolink_helper.get_ancestors("biolink:Drug")
biolink_helper.get_ancestors(["biolink:Drug", "biolink:Protein"])
biolink_helper.get_ancestors("biolink:Drug", include_mixins=False)
biolink_helper.get_ancestors("biolink:Protein", include_conflations=False)
biolink_helper.get_ancestors("biolink:treats")
Examples of ways to get descendants:
biolink_helper.get_descendants("biolink:ChemicalEntity")
biolink_helper.get_descendants(["biolink:ChemicalEntity", "biolink:Protein"])
biolink_helper.get_descendants("biolink:ChemicalEntity", include_mixins=False)
biolink_helper.get_descendants("biolink:Protein", include_conflations=False)
biolink_helper.get_descendants("biolink:related_to")
Ancestors/descendants are always returned in a list. Relevant mixins are included in the returned list by default, but you can turn that behavior off via the include_mixins parameter, as shown in some of the above examples. Inclusion of ARAX-defined conflations can be controlled via the include_conflations parameter (default is True).
Other available methods include getting canonical predicates:
biolink_helper.get_canonical_predicates("biolink:treated_by")
biolink_helper.get_canonical_predicates(["biolink:treated_by", "biolink:related_to"])
And filtering out mixins:
biolink_helper.filter_out_mixins(["biolink:ChemicalEntity", "biolink:PhysicalEssence"]])
You can also get the current ARAX Biolink version (parsed from the OpenAPI YAML) like so:
biolink_helper.get_current_arax_biolink_version()
Debugging
If desired, you can view the local copy of the BiolinkHelper's lookup map in your clone of the repo at RTX/code/ARAX/BiolinkHelper/biolink_lookup_map_X.Y.Z.json, where X.Y.Z is the Biolink version (e.g., 2.1.0).
Note that you must run an ARAX query in order for this map to be generated (after that first query, the map is never regenerated or updated for the given Biolink version). BiolinkHelper actually uses a pickle version of this map; the JSON version is just there for easier debugging/viewing.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file biolink_helper_pkg-0.2.0.tar.gz.
File metadata
- Download URL: biolink_helper_pkg-0.2.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a57c1f9bf0afbc52a6b8876b5bd760c0094cec26079b7227158dbc6d401720f2
|
|
| MD5 |
3410dea95a454f73c6bc20d017a0e892
|
|
| BLAKE2b-256 |
0368d33f85bc23a43618e6f16568d941287ccef08fcd4b368b45d77a3936208b
|
File details
Details for the file biolink_helper_pkg-0.2.0-py3-none-any.whl.
File metadata
- Download URL: biolink_helper_pkg-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b7e036e706ec48d30961758671bb8a28143e4e99e337eaa023792089f2b1bf2
|
|
| MD5 |
082a1989cdf4f96a052be40a8a36390e
|
|
| BLAKE2b-256 |
5c29aac048720d938b16f00db0a90ece19f1593afe23eb02d7c027dcc73a3aa4
|