aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bh20simplewebuploader/main.py23
-rw-r--r--bh20simplewebuploader/static/main.js4
-rw-r--r--bh20simplewebuploader/templates/demo.html14
3 files changed, 41 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 ]}"""
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index a9dfc10..751e478 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -89,6 +89,10 @@ let fetchCount = () => {
fetchAPI("/api/getCount");
}
+let fetchCountDB = () => {
+ fetchAPI("/api/getCountDB");
+}
+
let fetchSEQCountBySpecimen = () => {
fetchAPIV2("/api/getSEQCountbySpecimenSource");
}
diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html
index f0645b9..44aded0 100644
--- a/bh20simplewebuploader/templates/demo.html
+++ b/bh20simplewebuploader/templates/demo.html
@@ -5,11 +5,25 @@
{% include 'banner.html' %}
{% include 'menu.html' %}
{% include 'search.html' %}
+ <p>The Virtuoso database contains <span id="CounterDB"></span> public sequences!</p>
{% include 'demo-run.html' %}
{% include 'footer.html' %}
<script type="text/javascript">
let scriptRoot = {{ request.script_root|tojson|safe }}; // examples
+
+ document.addEventListener("DOMContentLoaded", function(){
+ var count = fetch("/api/getCountDB")
+ .then((resp) => resp.json())
+ .then(function (data) {
+ count = data["sequences"];
+ console.log(count);
+ span = document.getElementById("CounterDB");
+ txt = document.createTextNode(count);
+ span.appendChild(txt);
+ });
+ });
+
</script>
</body>