From 82f0aa6e3183e759a61a873826ab9da7b6e12468 Mon Sep 17 00:00:00 2001 From: lltommy Date: Sat, 14 Nov 2020 16:39:40 +0100 Subject: SPARQLplayground: Adding additional example --- bh20simplewebuploader/main.py | 22 ++++++++++++++++++++++ bh20simplewebuploader/static/main.css | 5 +++++ bh20simplewebuploader/static/main.js | 3 +++ bh20simplewebuploader/templates/demo.html | 11 ++++------- 4 files changed, 34 insertions(+), 7 deletions(-) (limited to 'bh20simplewebuploader') diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 87ef212..73787c2 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -1298,3 +1298,25 @@ ORDER BY ?country_label [{'seq': x['seq']['value'], 'country_label': x['country_label']['value']} for x in result]) + + +@app.route('/api/demoGetSeqByAgeGender', methods=['GET']) +def demoGetSeqByAgeGender(): + prefix = """PREFIX obo: +""" + query="""SELECT DISTINCT ?seq ?gender ?age WHERE { + ?seq ?hostSchema [ obo:PATO_0000047 ?sex] . + ?seq ?hostSchema [ obo:PATO_0000011 ?age ] . + ?sex rdfs:label ?gender . +} +Order by ?age +""" + + description = "List all sequences that have an entry in the field 'host_sex' and 'host_age'. Instead of the IRI we want to show the human readable label and order results by age" + 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}], + [{'seq': x['seq']['value'], + 'gender': x['gender']['value'], + 'age': x['age']['value']} for x in result]) \ No newline at end of file diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index 36c1a33..237b952 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -551,3 +551,8 @@ border: 1px solid black; padding-left:10px; padding-right:10px; } + +#playgroundButtonBox +{ +max-width: 80%; +} diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js index da196cf..1aa2582 100644 --- a/bh20simplewebuploader/static/main.js +++ b/bh20simplewebuploader/static/main.js @@ -234,6 +234,9 @@ let demoGetSouthAmericaSeq = () => { demofetchHTMLTable("/api/demoGetSouthAmericaSeq") } +let demoGetSeqByAgeGender = () => { + demofetchHTMLTable("/api/demoGetSeqByAgeGender") +} diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 393548c..742185b 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -19,22 +19,19 @@ -->
-
+
- - - - + - - + + -- cgit v1.2.3