aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlltommy2020-11-14 10:47:09 +0100
committerlltommy2020-11-14 10:47:09 +0100
commitee8424f4c8a06ab37ada1c17039e5a36289587b8 (patch)
treec1ce3b899974613026f74b468d4be1db99a880f6
parent0d7f1bc0000df215e85f0da1143703e311328dea (diff)
downloadbh20-seq-resource-ee8424f4c8a06ab37ada1c17039e5a36289587b8.tar.gz
bh20-seq-resource-ee8424f4c8a06ab37ada1c17039e5a36289587b8.tar.lz
bh20-seq-resource-ee8424f4c8a06ab37ada1c17039e5a36289587b8.zip
Adding an additional example to the SPARQL playground
-rw-r--r--bh20simplewebuploader/main.py43
-rw-r--r--bh20simplewebuploader/static/main.js62
-rw-r--r--bh20simplewebuploader/templates/demo.html16
3 files changed, 80 insertions, 41 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 27dcd4b..87ef212 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -1066,7 +1066,7 @@ def getSEQbyLocationAndSpecimenSource():
return str(result)
-################## SPARQL PLAYGORUND API function ################
+########################## SPARQL PLAYGORUND API function ####################
@app.route('/api/demoGetSEQCountbySpecimenSource', methods=['GET'])
def demoGetSEQCountbySpecimenSource():
@@ -1193,7 +1193,7 @@ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"""
@app.route('/api/demoGetSEQCountbytech', methods=['GET'])
-def dempGetSEQCountbytech():
+def demoGetSEQCountbytech():
prefix="""PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"""
@@ -1221,7 +1221,7 @@ def demoGetSequencePerDate():
FILTER ( xsd:date(?date) < xsd:date("2020-03-01") )
}
ORDER BY ?date"""
- description = "Show all sequences with a submission date before 2020-03-01! To accomplish this a FILTER expression is used. Since date is a string, we cast xsd:date(...)"
+ description = "Show all sequences with a collection date before 2020-03-01! To accomplish this a FILTER expression is used. Since date is a string, we cast xsd:date(...)"
payload = {'query': prefix + query, 'format': 'json'}
r = requests.get(sparqlURL, params=payload)
result = r.json()['results']['bindings']
@@ -1229,8 +1229,8 @@ def demoGetSequencePerDate():
[{'seq': x['seq']['value'],
'date': x['date']['value']} for x in result])
-@app.route('/api/demoLocationGps', methods=['GET'])
-def demoLocationGps():
+@app.route('/api/demoGetLocationGps', methods=['GET'])
+def demoGetLocationGps():
prefix="""PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX wiki: <http://www.wikidata.org/prop/direct/>"""
@@ -1247,8 +1247,8 @@ PREFIX wiki: <http://www.wikidata.org/prop/direct/>"""
[{'location': x['location']['value'],
'GPS': x['GPS']['value']} for x in result])
-@app.route('/api/getNYsamples', methods=['GET'])
-def getNYsamples():
+@app.route('/api/demoGetNYsamples', methods=['GET'])
+def demoGetNYsamples():
prefix="""PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX wikiE: <http://www.wikidata.org/entity/>"""
@@ -1270,4 +1270,31 @@ PREFIX wikiE: <http://www.wikidata.org/entity/>"""
'key_label': x['key_label']['value'],
'key': x['key']['value'],
'value_label': x['value_label']['value'],
- 'value': x['value']['value']} for x in result]) \ No newline at end of file
+ 'value': x['value']['value']} for x in result])
+
+
+@app.route('/api/demoGetSouthAmericaSeq', methods=['GET'])
+def demoGetSouthAmericaSeq():
+ prefix = """PREFIX obo: <http://purl.obolibrary.org/obo/>
+PREFIX wiki: <http://www.wikidata.org/prop/direct/>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+"""
+
+ query = """SELECT DISTINCT ?country_label ?seq WHERE
+ {
+ ?seq ?y [ obo:GAZ_00000448 ?location] .
+ ?location wiki:P17 ?country .
+ ?country rdfs:label ?country_label .
+ ?country wiki:P30 <http://www.wikidata.org/entity/Q18> .
+ }
+ORDER BY ?country_label
+"""
+
+ description = "Show all sequences that are on the continent (P30) South America (Q18)! List the sequence identifiers and the country they belong too."
+ 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'],
+ 'country_label': x['country_label']['value']} for x in result])
+
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 0e642c1..da196cf 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -164,29 +164,52 @@ let fetchCountDB = () => {
fetchAPI("/api/getCountDB");
}
+////// old API functions, some might no be used //
+let fetchSEQCountByTech = () => {
+ fetchHTMLTable("/api/getSEQCountbytech");
+}
+
+let fetchAllaccessions = () => {
+ fetchHTMLTable("/api/getAllaccessions");
+};
+
+let fetchMap = () => {
+ fetchAPI("/api/getCountByGPS");
+ updateMapMarkers();
+};
+
+let fetchSEQByLocation = () => {
+ console.log("Missing - set parameter for request, retrieve data")
+};
+
+let fetchSEQCountbyContinent = () => {
+ fetchHTMLTable("/api/getSEQCountbyContinent");
+}
+/////////////////////////////////// End "old" function
+
-//****** SPARQL playground functions // keep old functionality as comments for now, might be transfered elsewhere
-let fetchSEQCountBySpecimen = (toHTML) => {
+////****** SPARQL playground functions ***************////
+let demoFetchSEQCountBySpecimen = (toHTML) => {
//fetchHTMLTable("/api/getSEQCountbySpecimenSource");
demofetchHTMLTable("/api/demoGetSEQCountbySpecimenSource")
}
-let fetchSEQCountByLocation = () => {
+let demoFetchSEQCountByLocation = () => {
//fetchHTMLTable("/api/getSEQCountbyLocation");
demofetchHTMLTable("/api/demoGetSEQCountbyLocation")
}
//Get authors and there country/contitent where they come from
-let fetchAuthors = () => {
+let demoGetAuthors = () => {
demofetchHTMLTable("/api/demoGetAuthors")
}
// Fetch all institutes/originating labs and their associeted publications
-let fetchInstitutesPublications = () => {
+let demoFetchInstitutesPublications = () => {
demofetchHTMLTable("/api/demoInstitutesPublications")
}
-//Fetch seqeenctechnologies used by continent
+// Fetch sequence technology used by continent
let demoGetSEQCountbytechContinent = () => {
demofetchHTMLTable("/api/demoGetSEQCountbytechContinent")
}
@@ -199,35 +222,22 @@ let demoGetSequencePerDate = () => {
demofetchHTMLTable('/api/demoGetSequencePerDate')
}
-let demoLocationGps = () => {
- demofetchHTMLTable("/api/demoLocationGps")
+let demoGetLocationGps = () => {
+ demofetchHTMLTable("/api/demoGetLocationGps")
}
-let getNYsamples = () => {
- demofetchHTMLTable("/api/getNYsamples")
+let demoGetNYsamples = () => {
+ demofetchHTMLTable("/api/demoGetNYsamples")
}
-//old/unused functions
-let fetchSEQCountByTech = () => {
- fetchHTMLTable("/api/getSEQCountbytech");
+let demoGetSouthAmericaSeq = () => {
+ demofetchHTMLTable("/api/demoGetSouthAmericaSeq")
}
-let fetchAllaccessions = () => {
- fetchHTMLTable("/api/getAllaccessions");
-};
-let fetchMap = () => {
- fetchAPI("/api/getCountByGPS");
- updateMapMarkers();
-};
-let fetchSEQByLocation = () => {
- console.log("Missing - set parameter for request, retrieve data")
-};
-let fetchSEQCountbyContinent = () => {
- fetchHTMLTable("/api/getSEQCountbyContinent");
-}
+////****** SPARQL playground functions ***************////
/*
diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html
index ffebc91..393548c 100644
--- a/bh20simplewebuploader/templates/demo.html
+++ b/bh20simplewebuploader/templates/demo.html
@@ -21,17 +21,19 @@
<section class="search-section">
<div class="filter-options" action="#">
<div>
- <button class="button" onclick="fetchSEQCountByLocation()">Count by Location</button>
+ <button class="button" onclick="demoFetchSEQCountByLocation()">Count by Location</button>
<button class="button" onclick="demoGetSEQCountbytech()">Count by Sequencer</button>
- <button class="button" onclick="fetchInstitutesPublications()">Get list of publications</button>
- <button class="button" onclick="fetchSEQCountBySpecimen()">Count by Specimen source</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="getNYsamples()">Get all NY samples</button>
- <button class="button" onclick="fetchAuthors()">Get authors</button>
- <button class="button" onclick="demoGetSequencePerDate()">Show Sequences before submission date</button>
- <button class="button" onclick="demoLocationGps()">Locations and their GPS</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="demoGetSouthAmericaSeq()">List sequences from South America</button>
+
<!-- <button class="button" onclick="fetchAllaccessions()">Show All accessions</button>