aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader
diff options
context:
space:
mode:
authorlltommy2020-06-15 17:31:17 +0200
committerlltommy2020-06-15 17:31:17 +0200
commit802c4001340baa6f79c8107bb58add5dba9ad2b8 (patch)
tree9a9ec16328003b198fd960c5f10c0a03a894cad6 /bh20simplewebuploader
parentd18005b1880692cab16ecfc9e0c950abc4259087 (diff)
downloadbh20-seq-resource-802c4001340baa6f79c8107bb58add5dba9ad2b8.tar.gz
bh20-seq-resource-802c4001340baa6f79c8107bb58add5dba9ad2b8.tar.lz
bh20-seq-resource-802c4001340baa6f79c8107bb58add5dba9ad2b8.zip
Adding endpoints using grouping of continents
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r--bh20simplewebuploader/main.py40
-rw-r--r--bh20simplewebuploader/static/main.js3
-rw-r--r--bh20simplewebuploader/templates/demo-run.html1
3 files changed, 44 insertions, 0 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index b67e1bf..840070d 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -587,6 +587,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
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index d90b5af..1d2bcba 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -87,6 +87,9 @@ let fetchSEQByLocation = () => {
console.log("Missing - set parameter for request, retrieve data")
};
+let fetchSEQCountbyContinent = () => {
+ fetchAPIV2("/api/getSEQCountbyContinent");
+}
/*
diff --git a/bh20simplewebuploader/templates/demo-run.html b/bh20simplewebuploader/templates/demo-run.html
index 4479409..a80281c 100644
--- a/bh20simplewebuploader/templates/demo-run.html
+++ b/bh20simplewebuploader/templates/demo-run.html
@@ -6,6 +6,7 @@
<button class="button" onclick="fetchSEQCountByLocation()">Count by Location</button>
<button class="button" onclick="fetchSEQCountByTech()">Count by Sequencer</button>
<button class="button" onclick="fetchAllaccessions()">Show All accessions</button>
+ <button class="button" onclick="fetchSEQCountbyContinent()">Count by Continent</button>
<button class="button" onclick="fetchCountByGPS()">Map</button>
</div>