diff options
Diffstat (limited to 'bh20simplewebuploader/main.py')
-rw-r--r-- | bh20simplewebuploader/main.py | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index b67e1bf..40046c8 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -459,6 +459,13 @@ def about_page(): buf = get_html_body('doc/web/about.html') return render_template('about.html',menu='ABOUT',embed=buf) +## +@app.route('/map') +def map_page(): + return render_template('map.html',menu='DEMO') + + + ## Dynamic API functions starting here ## This is quick and dirty for now, just to get something out and demonstrate the queries ## Feel free to rename the functions/endpoints, feel free to process result so we get nicer JSON @@ -522,10 +529,10 @@ def getCountByGPS(): payload = {'query': query, 'format': 'json'} r = requests.get(baseURL, params=payload) result = r.json()['results']['bindings'] - return jsonify([{'Fasta Count': x['fastaCount']['value'], + return jsonify([{'count': x['fastaCount']['value'], 'Location': x['location']['value'], 'LocationLabel': x['location_label']['value'], - 'GPS' :x['GPS']['value']} for x in result]) + 'GPS' :x['GPS']['value'][6:-1]} for x in result]) @app.route('/api/getSEQCountbytech', methods=['GET']) @@ -587,6 +594,46 @@ def getSEQCountbyLocation(): 'label': x['geoLocation_label']['value']} for x in result]) +@app.route('/api/getSEQCountbyContinent', methods=['GET']) +def getSEQCountbyContinent(): + query="""SELECT DISTINCT ?continent ?continent_label (count(?fasta) as ?fastaCount) WHERE { + ?fasta ?x[ <http://purl.obolibrary.org/obo/GAZ_00000448> ?location] . + ?location <http://www.wikidata.org/prop/direct/P30> ?continent . + OPTIONAL { ?continent rdfs:label ?key_tmp_label } + BIND(IF(BOUND(?key_tmp_label),?key_tmp_label, ?location) as ?continent_label) + } + GROUP BY ?continent ?continent_label + """ + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + return jsonify([{'count': x['fastaCount']['value'], + 'key': x['continent']['value'], + 'label': x['continent_label']['value']} for x in result]) + + + +@app.route('/api/getSEQCountbyCountryContinent', methods=['GET']) +def getSEQCountbyCountryContinent(): + query="""SELECT DISTINCT ?location ?location_label (count(?fasta) as ?fastaCount) WHERE { + ?fasta ?x[ <http://purl.obolibrary.org/obo/GAZ_00000448> ?location] . + ?location <http://www.wikidata.org/prop/direct/P30> <placeholder> . + 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 + """ + continent = request.args.get('continent') + query = query.replace("placeholder", continent) + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + return jsonify([{'count': x['fastaCount']['value'], + 'key': x['location']['value'], + 'label': x['location_label']['value']} for x in result]) + + + @app.route('/api/getSEQCountbySpecimenSource', methods=['GET']) def getSEQCountbySpecimenSource(): query="""SELECT ?specimen_source ?specimen_source_label (count(?fasta) as ?fastaCount) WHERE |