From 6af08eac91a8b0d79e0cd7054e2a57e3e34c902a Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 8 Jan 2024 17:54:25 +0300 Subject: Optionally fetch dataset metadata if provided during probeset fetch. Signed-off-by: Munyoki Kilyungi --- gn3/api/metadata.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py index b3caa11..913d16a 100644 --- a/gn3/api/metadata.py +++ b/gn3/api/metadata.py @@ -896,7 +896,8 @@ CONSTRUCT { @metadata.route("/probesets/", methods=["GET"]) -def probesets(name): +@metadata.route("/probesets//", methods=["GET"]) +def probesets(name, dataset=""): """Fetch a probeset's metadata given it's name""" try: _query = Template(""" @@ -905,8 +906,12 @@ $prefix CONSTRUCT { ?probeset ?predicate ?object ; dct:references ?probesetResource ; - dct:references ?resource . - ?resource rdfs:label ?resourceLabel ; + dct:references ?resource ; + gnt:belongsToSpecies ?speciesShortName ; + gnt:belongsToGroup ?groupName ; + gnt:hasTissue ?tissueName ; + gnt:belongsToDataset ?datasetFullName . + ?resource rdfs:label ?resourceLabel ; rdfs:comments ?resourceComments . ?probesetResource rdfs:label ?probesetResourceLabel ; rdfs:comments ?probesetResourceComments . @@ -936,6 +941,22 @@ CONSTRUCT { ?probesetResourceLink rdfs:label ?probesetResourceLabel ; rdfs:comments ?probesetResourceComments . } . + OPTIONAL { + ?dataset rdf:type dcat:Dataset ; + (rdfs:label|dct:identifier|skos:prefLabel) "HC_M2_0606_P" ; + (skos:altLabel|skos:prefLabel) ?datasetFullName . + } . + OPTIONAL { + ?dataset gnt:hasTissue ?tissue . + ?tissue rdfs:label ?tissueName . + } . + OPTIONAL { + ?inbredSet ^skos:member gnc:Set ; + ^gnt:belongsToGroup ?dataset ; + rdfs:label ?groupName ; + xkos:generalizes ?species . + ?species gnt:shortName ?speciesShortName . + } . } """).substitute(prefix=RDF_PREFIXES, name=name) _context = { @@ -953,6 +974,9 @@ CONSTRUCT { "dct": "http://purl.org/dc/terms/", "description": "dct:description", "geneID": "gnt:hasGeneId", + "group": "gnt:belongsToGroup", + "dataset": "gnt:belongsToDataset", + "tissue": "gnt:hasTissue", "kgID": "gnt:hasKgID", "location": "gnt:location", "mb": "gnt:mb", -- cgit v1.2.3