Skip to content

xref-to-bkbit_id api endpoint #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: ingestion_service_v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions query_service/core/routers/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://w3id.org/biolink/vocab/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@puja since we are using the named graphs, please update the query to include the named graphs. I would suggest to include the named graph as one of the input that you can request from the user.

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

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(
Expand Down