aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader/main.py
diff options
context:
space:
mode:
authorPjotr Prins2020-07-12 11:08:27 +0100
committerPjotr Prins2020-07-12 11:08:27 +0100
commitfba4474b5e2e7c069bb9158089ecb873ff8e6c5c (patch)
tree27b7375f37e44f82e6c0593006f9f29c17d011be /bh20simplewebuploader/main.py
parent83f5a382ef37ddfddf3ec64d553362b71d53ab01 (diff)
downloadbh20-seq-resource-fba4474b5e2e7c069bb9158089ecb873ff8e6c5c.tar.gz
bh20-seq-resource-fba4474b5e2e7c069bb9158089ecb873ff8e6c5c.tar.lz
bh20-seq-resource-fba4474b5e2e7c069bb9158089ecb873ff8e6c5c.zip
CounterDB
Diffstat (limited to 'bh20simplewebuploader/main.py')
-rw-r--r--bh20simplewebuploader/main.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 8f9b99b..77e345b 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -567,11 +567,34 @@ baseURL='http://sparql.genenetwork.org/sparql/'
@app.route('/api/getCount', methods=['GET'])
def getCount():
+ """
+ Get sequence counts from Arvados record
+ """
api = arvados.api(host=ARVADOS_API, token=ANONYMOUS_TOKEN, insecure=True)
c = api.collections().list(filters=[["owner_uuid", "=", VALIDATED_PROJECT]], limit=1).execute()
return jsonify({'sequences': c["items_available"]})
+@app.route('/api/getCountDB', methods=['GET'])
+def getCountDB():
+ """
+ Get sequence counts from Virtuoso DB
+ """
+ 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 ]}"""