aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader
diff options
context:
space:
mode:
authorlltommy2020-11-14 18:51:42 +0100
committerlltommy2020-11-14 18:51:42 +0100
commit5867eb6953e2e6564eb79d6f824952ce0bf2e28b (patch)
tree7ac0debba0479f309a4653075159f230eb925268 /bh20simplewebuploader
parent82f0aa6e3183e759a61a873826ab9da7b6e12468 (diff)
downloadbh20-seq-resource-5867eb6953e2e6564eb79d6f824952ce0bf2e28b.tar.gz
bh20-seq-resource-5867eb6953e2e6564eb79d6f824952ce0bf2e28b.tar.lz
bh20-seq-resource-5867eb6953e2e6564eb79d6f824952ce0bf2e28b.zip
SPARQL playground: additional examples
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r--bh20simplewebuploader/main.py72
-rw-r--r--bh20simplewebuploader/static/main.js9
-rw-r--r--bh20simplewebuploader/templates/demo.html12
3 files changed, 88 insertions, 5 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 73787c2..ea4ec10 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -1261,7 +1261,7 @@ PREFIX wikiE: <http://www.wikidata.org/entity/>"""
}
ORDER BY ?seq"""
- description = "Get all samples and their information (key, values) that were taken in New York (Q1384)!"
+ description = "Get all sequences and all sequence information (key, values) that were taken in New York (Q1384)!"
payload = {'query': prefix + query, 'format': 'json'}
r = requests.get(sparqlURL, params=payload)
result = r.json()['results']['bindings']
@@ -1319,4 +1319,72 @@ Order by ?age
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
+ 'age': x['age']['value']} for x in result])
+
+
+@app.route('/api/demoGetSeqIllumina', methods=['GET'])
+def demoGetSeqIllumina():
+ prefix = """PREFIX obo: <http://purl.obolibrary.org/obo/>
+PREFIX efo: <http://www.ebi.ac.uk/efo/>"""
+ ##TODO adjust OBI_0600047 to NCIT_C153598 once new schema is live
+ query="""SELECT DISTINCT ?seq WHERE {
+?seq ?technologySchema [obo:OBI_0600047 efo:EFO_0008635 ]
+}"""
+
+
+ description = "List all sequences that have as 'sample_sequencing_technology' (NCIT_C153598) Illumina iSeq 100 (EFO_0008635)"
+ 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']} for x in result])
+
+
+
+
+@app.route('/api/demoGetSeqWithStrain', methods=['GET'])
+def demoGetSeqWithStrain():
+ prefix = """PREFIX SIO: <http://semanticscience.org/resource/>"""
+ query="""SELECT DISTINCT ?strain ?seq WHERE {
+?seq ?virusSchema [SIO:SIO_010055 ?strain]
+}"""
+
+ description = "List all sequences with data in 'virus_strain'. Show the strain and the relevant identifer!"
+ 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}],
+ [{'strain': x['strain']['value'],
+ 'seq': x['seq']['value']} for x in result])
+
+
+
+@app.route('/api/demoGetContinentSpecimentSeqCount', methods=['GET'])
+def demoGetContinentSpecimentSeqCount():
+ prefix = """PREFIX obo: <http://purl.obolibrary.org/obo/>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX wiki: <http://www.wikidata.org/prop/direct/>"""
+ query="""SELECT ?continent_label ?specimen_source_label (count(?seq) as ?seqCount) WHERE
+ {
+ ?seq ?x [obo:OBI_0001479 ?specimen_source] .
+ ?seq ?y [ obo:GAZ_00000448 ?location] .
+
+ ?location wiki:P17 ?country .
+ ?location wiki:P30 ?continent .
+
+ ?specimen_source rdfs:label ?specimen_source_label .
+ ?continent rdfs:label ?continent_label.
+ }
+
+ GROUP BY ?specimen_source ?specimen_source_label ?continent_label
+ ORDER BY ?continent_label DESC(?seqCount)"""
+
+ description = "Show a count of sequences by continent and specimen_source. For readability the labels for specimen_source and ?continent are retrieved."
+ 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}],
+ [{'continent_label': x['continent_label']['value'],
+ 'specimen_source_label': x['specimen_source_label']['value'],
+ 'seqCount': x['seqCount']['value']} for x in result])
+
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 1aa2582..aa1f06f 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -238,7 +238,16 @@ let demoGetSeqByAgeGender = () => {
demofetchHTMLTable("/api/demoGetSeqByAgeGender")
}
+let demoGetSeqIllumina = () => {
+ demofetchHTMLTable("/api/demoGetSeqIllumina")
+}
+let demoGetSeqWithStrain = () => {
+ demofetchHTMLTable("/api/demoGetSeqWithStrain")
+}
+let demoGetContinentSpecimentSeqCount = () => {
+ demofetchHTMLTable("/api/demoGetContinentSpecimentSeqCount")
+}
////****** SPARQL playground functions ***************////
diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html
index 742185b..dc6281d 100644
--- a/bh20simplewebuploader/templates/demo.html
+++ b/bh20simplewebuploader/templates/demo.html
@@ -21,17 +21,23 @@
<section class="search-section">
<div id="playgroundButtonBox" class="filter-options" action="#">
<div>
- <button class="button" onclick="demoFetchSEQCountByLocation()">Count by Location</button>
- <button class="button" onclick="demoGetSEQCountbytech()">Count by Sequencer</button>
+ <button class="button" onclick="demoFetchSEQCountByLocation()">Count by location</button>
+ <button class="button" onclick="demoGetSEQCountbytech()">Count by sequencer</button>
+ <button class="button" onclick="demoGetSeqIllumina()">Sequences done with Illumina iSeq 100</button>
<button class="button" onclick="demoFetchInstitutesPublications()">Get list of publications</button>
+ <button class="button" onclick="demoGetSeqWithStrain()">Sequences and their virus_strain</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="demoGetAuthors()">Get authors</button>
<button class="button" onclick="demoGetLocationGps()">Locations and their GPS</button>
- <button class="button" onclick="demoGetSequencePerDate()">Show Sequences by collection date</button>
+ <button class="button" onclick="demoGetSequencePerDate()">Show sequences by collection date</button>
<button class="button" onclick="demoGetSouthAmericaSeq()">List sequences from South America</button>
<button class="button" onclick="demoGetSeqByAgeGender()">Get Sequence by age and gender</button>
<button class="button" onclick="demoGetNYsamples()">Get all NY samples</button>
+ <button class="button" onclick="demoGetContinentSpecimentSeqCount()">Sequence count by continent/specimen_source</button>
+
+
+
<!-- <button class="button" onclick="fetchAllaccessions()">Show All accessions</button>
<button class="button" onclick="fetchSEQCountbyContinent()">Count by Continent</button>-->