TCT.translator_query

TCT.translator_query.get_translator_API_predicates()[source]

Get the predicates supported by each API.

Returns:
A dictionary of API names and their predicates.

Examples

>>> API_predicates = get_translator_API_predicates()
TCT.translator_query.optimize_query_json(query_json, API_name_cur, API_predicates)[source]

Optimize the query JSON by removing predicates that are not supported by the selected APIs.

Parameters:
query_json1str

a query in TRAPI 1.5.0 format

API_name_curstr

the name of the API to query

API_predicatesdict

a dictionary of API names and their predicates

Returns:
A modified query JSON with only the predicates supported by the selected APIs.

Examples

>>> 
TCT.translator_query.parallel_api_query(query_json, select_APIs, APInames, API_predicates, max_workers=1)[source]

Queries multiple APIs in parallel and merges the results into a single knowledge graph.

Parameters:
URLS

list of API URLs to query

query_json

the query JSON to be sent to each API

max_workers

number of parallel workers to use for querying

Returns:
Returns a merged knowledge graph from all successful API responses.

Examples

>>> result = TCT.parallel_api_query(API_URLs,query_json=query_json, max_workers=len(API_URLs1))
TCT.translator_query.query_KP(API_name_cur, query_json, APInames, API_predicates)[source]

Query an individual API with a TRAPI 1.5.0 query JSON, without modifying the original query_json.