diff options
author | lltommy | 2020-11-14 16:39:40 +0100 |
---|---|---|
committer | lltommy | 2020-11-14 16:39:40 +0100 |
commit | 82f0aa6e3183e759a61a873826ab9da7b6e12468 (patch) | |
tree | f921c4d4e4d37fce028950976792ccd2cbcc184c /bh20simplewebuploader | |
parent | ee8424f4c8a06ab37ada1c17039e5a36289587b8 (diff) | |
download | bh20-seq-resource-82f0aa6e3183e759a61a873826ab9da7b6e12468.tar.gz bh20-seq-resource-82f0aa6e3183e759a61a873826ab9da7b6e12468.tar.lz bh20-seq-resource-82f0aa6e3183e759a61a873826ab9da7b6e12468.zip |
SPARQLplayground: Adding additional example
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r-- | bh20simplewebuploader/main.py | 22 | ||||
-rw-r--r-- | bh20simplewebuploader/static/main.css | 5 | ||||
-rw-r--r-- | bh20simplewebuploader/static/main.js | 3 | ||||
-rw-r--r-- | bh20simplewebuploader/templates/demo.html | 11 |
4 files changed, 34 insertions, 7 deletions
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: <http://purl.obolibrary.org/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 @@ --> <section class="search-section"> - <div class="filter-options" action="#"> + <div id="playgroundButtonBox" class="filter-options" action="#"> <div> <button class="button" onclick="demoFetchSEQCountByLocation()">Count by Location</button> <button class="button" onclick="demoGetSEQCountbytech()">Count by Sequencer</button> <button class="button" onclick="demoFetchInstitutesPublications()">Get list of publications</button> <button class="button" onclick="demoFetchSEQCountBySpecimen()">Count by Specimen source</button> <button class="button" onclick="demoGetSEQCountbytechContinent()">Sequence Technologies used by continent</button> - <button class="button" onclick="demoGetNYsamples()">Get all NY samples</button> <button class="button" onclick="demoGetAuthors()">Get authors</button> - <button class="button" onclick="demoGetSequencePerDate()">Show Sequences by collection date</button> <button class="button" onclick="demoGetLocationGps()">Locations and their GPS</button> - - + <button class="button" onclick="demoGetSequencePerDate()">Show Sequences by collection date</button> <button class="button" onclick="demoGetSouthAmericaSeq()">List sequences from South America</button> - - + <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="fetchAllaccessions()">Show All accessions</button> <button class="button" onclick="fetchSEQCountbyContinent()">Count by Continent</button>--> |