From 2d201e156d530e5e912252c4300245da382b846e Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 16 May 2020 10:14:13 -0500 Subject: Counting number of sequences --- bh20simplewebuploader/main.py | 17 +++++++++++++++++ bh20simplewebuploader/static/main.js | 5 ++++- bh20simplewebuploader/templates/form.html | 21 +++++++++++++++++---- 3 files changed, 38 insertions(+), 5 deletions(-) (limited to 'bh20simplewebuploader') diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 1dff207..0ba43fd 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -424,6 +424,23 @@ def receive_files(): ## but most likley you don't want to touch the queries, Cheers. baseURL='http://sparql.genenetwork.org/sparql/' +@app.route('/api/getCount', methods=['GET']) +def getCount(): + query=""" +PREFIX pubseq: +select (COUNT(distinct ?dataset) as ?num) +{ + ?dataset pubseq:submitter ?id . + ?id ?p ?submitter +} +""" + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + # [{'num': {'type': 'typed-literal', 'datatype': 'http://www.w3.org/2001/XMLSchema#integer', 'value': '1352'}}] + # print(result, file=sys.stderr) + return jsonify({'sequences': int(result[0]["num"]["value"])}) + @app.route('/api/getAllaccessions', methods=['GET']) def getAllaccessions(): query="""SELECT DISTINCT ?fasta ?value WHERE {?fasta ?x[ ?value ]}""" diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js index 7084e1f..bf95832 100644 --- a/bh20simplewebuploader/static/main.js +++ b/bh20simplewebuploader/static/main.js @@ -18,6 +18,10 @@ let search = () => { fetchAPI(scriptRoot + "/api/getDetailsForSeq?seq=" + encodeURIComponent(m)); } +let fetchCount = () => { + fetchAPI("/api/getCount"); +} + let fetchSEQBySpecimen = () => { fetchAPI("/api/getSEQCountbySpecimenSource"); } @@ -160,7 +164,6 @@ for (let button of document.getElementsByClassName('remove-field')) { } // Change the submit button after hitting - function on_submit_button() { var elem = document.getElementById("submit"); elem.value = "Submitting..."; diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html index 7d7cef8..2cbaf62 100644 --- a/bh20simplewebuploader/templates/form.html +++ b/bh20simplewebuploader/templates/form.html @@ -6,13 +6,14 @@ Web uploader for Public SARS-CoV-2 Sequence Resource +

Web uploader for Public SARS-CoV-2 Sequence Resource

-Disabled until we got everything wired up +

Database contains public sequences!

@@ -209,9 +210,21 @@ - - + -- cgit v1.2.3