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/main.py | |
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/main.py')
-rw-r--r-- | bh20simplewebuploader/main.py | 22 |
1 files changed, 22 insertions, 0 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 |