aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader/main.py
diff options
context:
space:
mode:
authorPjotr Prins2020-05-16 10:14:13 -0500
committerPjotr Prins2020-05-16 10:14:13 -0500
commit2d201e156d530e5e912252c4300245da382b846e (patch)
treea2cb50022c93b5f508d47b6ece99a0063c92687e /bh20simplewebuploader/main.py
parent6dc16e60eb16cddb3ca1528561734e44507bf1cc (diff)
downloadbh20-seq-resource-2d201e156d530e5e912252c4300245da382b846e.tar.gz
bh20-seq-resource-2d201e156d530e5e912252c4300245da382b846e.tar.lz
bh20-seq-resource-2d201e156d530e5e912252c4300245da382b846e.zip
Counting number of sequences
Diffstat (limited to 'bh20simplewebuploader/main.py')
-rw-r--r--bh20simplewebuploader/main.py17
1 files changed, 17 insertions, 0 deletions
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: <http://biohackathon.org/bh20-seq-schema#MainSchema/>
+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[ <http://edamontology.org/data_2091> ?value ]}"""