aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlltommy2020-11-19 23:55:59 +0100
committerlltommy2020-11-19 23:55:59 +0100
commit6814f9d74ca1d7fe4a7a08e5df0878557bd8e8f1 (patch)
tree3cdf797006361e616a945fa4cf56d758d99ccf97
parentfd4b04479fb85f01d2cb2e582e9e470296b8b3cf (diff)
downloadbh20-seq-resource-6814f9d74ca1d7fe4a7a08e5df0878557bd8e8f1.tar.gz
bh20-seq-resource-6814f9d74ca1d7fe4a7a08e5df0878557bd8e8f1.tar.lz
bh20-seq-resource-6814f9d74ca1d7fe4a7a08e5df0878557bd8e8f1.zip
Adding another example to the SPARQL playground
-rw-r--r--bh20simplewebuploader/main.py19
-rw-r--r--bh20simplewebuploader/static/main.js4
-rw-r--r--bh20simplewebuploader/templates/demo.html2
3 files changed, 24 insertions, 1 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 9823e11..d6e5249 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -1387,3 +1387,22 @@ PREFIX wiki: <http://www.wikidata.org/prop/direct/>"""
[{'continent_label': x['continent_label']['value'],
'specimen_source_label': x['specimen_source_label']['value'],
'seqCount': x['seqCount']['value']} for x in result])
+
+
+@app.route('/api/demoGetSampleSchema', methods=['GET'])
+def demoGetSampleSchema():
+ prefix = """PREFIX bh:<http://biohackathon.org/bh20-seq-schema#MainSchema/>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"""
+ query="""Select distinct ?key ?key_label WHERE {
+ ?seq bh:sample [?key ?value ] .
+ ?key rdfs:label ?key_label
+}
+"""
+
+ description = "Show the sample meta data schema. Displays the keys as well as their labels. By simple replacing bh:sample e.g. bh:technology the user could retrieve other parts of the meta data schema"
+ payload = {'query': prefix + query, 'format': 'json'}
+ r = requests.get(sparqlURL, params=payload)
+ result = r.json()['results']['bindings']
+ return jsonify([{'description': description}, {'prefix': prefix}, {'query': query}],
+ [{'key': x['key']['value'],
+ 'key_label': x['key_label']['value']} for x in result])
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 8baf635..d061f8e 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -254,6 +254,10 @@ let demoGetContinentSpecimentSeqCount = () => {
demofetchHTMLTable("/api/demoGetContinentSpecimentSeqCount")
}
+let demoGetSampleSchema= () => {
+ demofetchHTMLTable("/api/demoGetSampleSchema")
+}
+
////****** SPARQL playground functions ***************////
diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html
index dc6281d..8010a1b 100644
--- a/bh20simplewebuploader/templates/demo.html
+++ b/bh20simplewebuploader/templates/demo.html
@@ -35,7 +35,7 @@
<button class="button" onclick="demoGetSeqByAgeGender()">Get Sequence by age and gender</button>
<button class="button" onclick="demoGetNYsamples()">Get all NY samples</button>
<button class="button" onclick="demoGetContinentSpecimentSeqCount()">Sequence count by continent/specimen_source</button>
-
+ <button class="button" onclick="demoGetSampleSchema()">Show sample meta data schema</button>