TCT.trapi¶
This is a wrapper around making calls to the Translator Reasoner API (TRAPI).
API Documentation: https://github.com/NCATSTranslator/ReasonerAPI
Additional API Documentation: https://github.com/NCATSTranslator/ReasonerAPI/blob/master/docs/reference.md
- TCT.trapi.build_query(subject_ids: list[str], object_categories: list[str], predicates: list[str], return_json: bool = True, object_ids=None, subject_categories=None)[source]¶
This constructs a query json for use with TRAPI. Queries are of the form [subject_ids]-[predicates]-[object_categories]. The output for the query contains all the subject-predicate-object triples where the subject is in subject_ids, the object’s category is in object_categories, and the predicate for the edge is in predicates.
For a description of the existing biolink categories and predicates, see https://biolink.github.io/biolink-model/
- Returns:
- A json string
Examples
In this example, we want all genes that physically interact with gene 3845. >>> build_query([‘NCBIGene:3845’], [‘biolink:Gene’], [‘biolink:physically_interacts_with’]) “{‘message’: {‘query_graph’: {
‘edges’: {‘e00’: {‘subject’: ‘n00’, ‘object’: ‘n01’, ‘predicates’:[‘biolink:physically_interacts_with]}}, ‘nodes’: {‘n00’: {‘ids’: [‘NCBIGene:3845’]}, ‘n01’: {‘categories’: [‘biolink’:Gene’]}}}}}”