Skip to content

Commit

Permalink
improve how @annotations are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Sep 21, 2023
1 parent 584ed86 commit d7ccb17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
24 changes: 14 additions & 10 deletions backend/app/api/nanopub.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,18 @@ def get_np_config(user_id: str) -> NanopubConf:
"dct": "http://purl.org/dc/terms/",
"biolink": "https://w3id.org/biolink/vocab/"
},
"@type": "biolink:Drug",
"biolink:category": "biolink:Drug",
"biolink:id": "drugbank:DB00001",
"rdfs:label": "Lepirudin",
"dct:description": "Lepirudin is a protein-based direct thrombin inhibitor."
"@type": "biolink:Association",
"biolink:category": "biolink:Association",
"rdf:subject": {"@id": "drugbank:DB00001"},
"rdf:predicate": {"@id": "biolink:treats"},
"rdf:object": {"@id": "MONDO:0004975"},
# "@annotations": {
# "@context": {
# "ml": "https://w3id.org/YOUR_ML_SCHEMA/"
# },
# "ml:algorithm": "nearest neightbor",
# "ml:weight": 0.6,
# }
}
# ASSERTION_EXAMPLE = [
# {
Expand Down Expand Up @@ -165,6 +172,8 @@ async def publish_assertion(
)

if annotations_rdf:
# Make sure annotations have the assertion as subject
annotations_rdf["@id"] = np.assertion.identifier
np.provenance.parse(data=annotations_rdf, format="json-ld")
if source:
np.provenance.add((np.assertion.identifier, PROV.hadPrimarySource, URIRef(source)))
Expand Down Expand Up @@ -448,15 +457,12 @@ async def store_keyfile(
# response_model={},
# )
# async def download_keyfile(current_user: models.User = Depends(get_current_user)):

# if not current_user or "id" not in current_user.keys():
# raise HTTPException(
# status_code=403,
# detail=f"You need to login to download the keys associated with your ORCID",
# )

# user_dir = Path(f"{settings.KEYSTORE_PATH}/{current_user['sub']}")

# if user_dir.exists():
# # shutil.make_archive(f"{user_dir}/nanopub_profile.zip", 'zip', user_dir)
# zip_filename = "nanopub_profile.zip"
Expand All @@ -470,14 +476,12 @@ async def store_keyfile(
# print(os.path.join(root, fpath))
# zf.write(os.path.join(root, fpath), fpath)
# zf.close()

# # Grab ZIP file from in-memory, make response with correct MIME-type
# return Response(
# s.getvalue(),
# media_type="application/x-zip-compressed",
# headers={"Content-Disposition": f"attachment;filename={zip_filename}"},
# )

# return JSONResponse(
# {
# "message": "No files has been found on our servers for the ORCID user "
Expand Down
2 changes: 1 addition & 1 deletion backend/app/trapi/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def add_process_time_header(request: Request, call_next):
start_time = time.time()
response = await call_next(request)
process_time = time.time() - start_time
response.headers["X-Process-Time"] = str(process_time)
response.headers["Server-Timing"] = f"total;dur={process_time}"
return response


Expand Down
4 changes: 1 addition & 3 deletions backend/app/trapi/reasonerapi_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,11 @@
)

# Load BioLink JSON-LD Context to resolve URIs to BioLink CURIEs
# try:
with urllib.request.urlopen(
f"https://raw.githubusercontent.com/biolink/biolink-model/v{settings.BIOLINK_VERSION}/context.jsonld"
) as url:
data = json.loads(url.read().decode())
# except Exception:
# print('Error download BioLink model JSON-LD from GitHub')


namespace_resolver = {}
context = data["@context"]
Expand Down

0 comments on commit d7ccb17

Please sign in to comment.