diff options
author | lltommy | 2020-04-26 12:22:55 +0200 |
---|---|---|
committer | lltommy | 2020-04-26 12:22:55 +0200 |
commit | fd29a73ae0ea231e91377776dd5b8fa18b5ba5e2 (patch) | |
tree | b696d0d99a9a0f9abe8d7215a8e25bec34c81334 /bh20simplewebuploader | |
parent | 976f0978b38ffcce090fecbf4c04cb7aeec8239c (diff) | |
download | bh20-seq-resource-fd29a73ae0ea231e91377776dd5b8fa18b5ba5e2.tar.gz bh20-seq-resource-fd29a73ae0ea231e91377776dd5b8fa18b5ba5e2.tar.lz bh20-seq-resource-fd29a73ae0ea231e91377776dd5b8fa18b5ba5e2.zip |
Adding a function, correcting some variable names
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r-- | bh20simplewebuploader/main.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 53a4cda..75adc74 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -378,17 +378,33 @@ def getDetailsForSeq(): @app.route('/api/getSEQbytech', methods=['GET']) def getSEQbytech(): - query="""SELECT ?specimen_source ?specimen_source_label (count(?fasta) as ?fastaCount) WHERE - {?fasta ?x [<http://purl.obolibrary.org/obo/OBI_0600047> ?specimen_source] - BIND (concat(?specimen_source,"_label") as ?specimen_source_label)} - GROUP BY ?specimen_source ?specimen_source_label ORDER BY DESC (?fastaCount) + query="""SELECT ?tech ?tech_label (count(?fasta) as ?fastaCount) WHERE + {?fasta ?x [<http://purl.obolibrary.org/obo/OBI_0600047> ?tech] + BIND (concat(?tech,"_label") as ?tech_label)} + GROUP BY ?tech ?tech_label ORDER BY DESC (?fastaCount) """ payload = {'query': query, 'format': 'json'} r = requests.get(baseURL, params=payload) result = r.json()['results']['bindings'] return jsonify([{'Fasta Count': x['fastaCount']['value'], - 'Specimen Source': x['specimen_source']['value'], - 'Label': x['specimen_source_label']['value']} for x in result]) + 'tech': x['tech']['value'], + 'Label': x['tech_label']['value']} for x in result]) + + +## List all Sequences/submissions by a given tech, as example e.g. http://purl.obolibrary.org/obo/OBI_0000759 +## Has to be encoded again so should be --> http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FOBI_0000759 +@app.route('/api/getSEQbySelectedtech', methods=['GET']) +def getSEQbySelectedtech(): + query="""SELECT ?fasta WHERE + {?fasta ?x [<http://purl.obolibrary.org/obo/OBI_0600047> <placeholder>] } + """ + tech = request.args.get('tech') + query=query.replace("placeholder", tech) + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + return str(result) + @app.route('/api/getSEQbyLocation', methods=['GET']) def getSEQbyLocation(): |