diff --git a/query_service/core/routers/query.py b/query_service/core/routers/query.py index 7fb4011..b24092e 100644 --- a/query_service/core/routers/query.py +++ b/query_service/core/routers/query.py @@ -53,6 +53,27 @@ async def get_named_graphs(): } return response_graph +@router.get("query/xref-to-bkbit") +async def get_bkbit_id(xref): + query_bkbit_id = f""" + PREFIX biolink: + PREFIX xsd: + + SELECT DISTINCT ?bkbit_id + WHERE {{ + ?bkbit_id biolink:xref "{xref}"^^xsd:anyURI . + }} + """ + + response = fetch_data_gdb(query_bkbit_id) + return { + "xref": xref, + "matched_ids": [ + binding["bkbit_id"]["value"] + for binding in response["message"]["results"]["bindings"] + ] + } + @router.get("/query/sparql/", include_in_schema=False) async def sparql_query(