diff options
author | lltommy | 2020-06-12 22:39:58 +0200 |
---|---|---|
committer | lltommy | 2020-06-12 22:39:58 +0200 |
commit | a8674b7e5c726994a102ea8c47d0e82c12e23d51 (patch) | |
tree | 7c04b1e0e12ca6797dd9b869060c27cde5c355f8 /bh20simplewebuploader/main.py | |
parent | 5ecad64519164a60d130d461db5c773cc17a501d (diff) | |
download | bh20-seq-resource-a8674b7e5c726994a102ea8c47d0e82c12e23d51.tar.gz bh20-seq-resource-a8674b7e5c726994a102ea8c47d0e82c12e23d51.tar.lz bh20-seq-resource-a8674b7e5c726994a102ea8c47d0e82c12e23d51.zip |
Adding endpoint getCountByGPS which could be used to draw a map
Diffstat (limited to 'bh20simplewebuploader/main.py')
-rw-r--r-- | bh20simplewebuploader/main.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 0cc22df..851d8d5 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -508,6 +508,25 @@ def getDetailsForSeq(): return jsonify([{'uri': x['key']['value'], 'key_label': x['key_label']['value'], 'value': x['value']['value']} for x in result]) +# Endpoint should provide all necessary information to draw a map (!) +@app.route('/api/getCountByGPS', methods=['GET']) +def getCountByGPS(): + query="""SELECT DISTINCT ?location ?location_label ?GPS (count(?fasta) as ?fastaCount) WHERE { + ?fasta ?x[ <http://purl.obolibrary.org/obo/GAZ_00000448> ?location] . + ?location <http://www.wikidata.org/prop/direct/P625> ?GPS . + OPTIONAL { ?location rdfs:label ?key_tmp_label } + BIND(IF(BOUND(?key_tmp_label),?key_tmp_label, ?location) as ?location_label) + } + GROUP BY ?location ?location_label ?GPS + """ + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + return jsonify([{'Fasta Count': x['fastaCount']['value'], + 'Location': x['location']['value'], + 'LocationLabel': x['location_label']['value'], + 'GPS' :x['GPS']['value']} for x in result]) + @app.route('/api/getSEQCountbytech', methods=['GET']) def getSEQCountbytech(): |