aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader
diff options
context:
space:
mode:
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r--bh20simplewebuploader/main.py53
-rw-r--r--bh20simplewebuploader/static/main.css27
-rw-r--r--bh20simplewebuploader/static/main.js6
-rw-r--r--bh20simplewebuploader/templates/blog.html5
-rw-r--r--bh20simplewebuploader/templates/home.html29
-rw-r--r--bh20simplewebuploader/templates/menu.html2
-rw-r--r--bh20simplewebuploader/templates/resource.html4
7 files changed, 110 insertions, 16 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 73503b4..1d7154c 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -7,6 +7,7 @@ import logging
import os
import sys
import re
+import redis
import string
import ruamel.yaml as yaml
import pkg_resources
@@ -252,8 +253,19 @@ def send_home():
"""
Send the front page.
"""
-
- return render_template('home.html', menu='HOME', load_map=True)
+ redis_client = redis.Redis(host=os.environ.get('HOST', 'localhost'),
+ port=os.environ.get('PORT', 6379),
+ db=os.environ.get('REDIS_DB', 0))
+ tweets = []
+ for tweet_id in redis_client.zrevrange('bh20-tweet-score:',
+ 0, -1):
+ tweets.append(
+ {k.decode("utf-8"): v.decode("utf-8") for k, v in
+ redis_client.hgetall(tweet_id).items()}
+ )
+ return render_template('home.html', menu='HOME',
+ tweets=tweets,
+ load_map=True)
@app.route('/upload')
@@ -675,13 +687,32 @@ sparqlURL='http://sparql.genenetwork.org/sparql/'
@app.route('/resource/<id>')
def resource(id):
"""Get a COVID19 resource using identifier"""
+
query=f"""
PREFIX pubseq: <http://biohackathon.org/bh20-seq-schema#MainSchema/>
PREFIX sio: <http://semanticscience.org/resource/>
select distinct ?sample ?geoname ?date ?source ?geo ?sampletype ?institute ?sequenceuri
+where {{
{{
?sample sio:SIO_000115 "{id}" .
?sequenceuri pubseq:sample ?sample .
+}}
+union
+{{
+ <http://collections.lugli.arvadosapi.com/c={id}/sequence.fasta> pubseq:sample ?sample .
+ ?sequenceuri pubseq:sample ?sample .
+}}
+union
+{{
+ <http://covid19.genenetwork.org/resource/{id}> pubseq:sample ?sample .
+ ?sequenceuri pubseq:sample ?sample .
+}}
+union
+{{
+ ?sequenceuri <http://biohackathon.org/bh20-seq-schema/collection_pdh> "{id}" .
+ ?sequenceuri pubseq:sample ?sample .
+}}
+
?sample <http://purl.obolibrary.org/obo/GAZ_00000448> ?geo .
?geo rdfs:label ?geoname .
?sample <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164> ?date .
@@ -699,8 +730,9 @@ select distinct ?sample ?geoname ?date ?source ?geo ?sampletype ?institute ?sequ
logging.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
# return jsonify({'sequences': int(result[0]["num"]["value"])})
sequenceuri=sample['sequenceuri']['value']
- collectionuri=sequenceuri.split('sequence.fasta')[0]
- metauri=collectionuri+'metadata.yaml'
+ m = re.match(r"http://collections.lugli.arvadosapi.com/c=([^/]*)/sequence.fasta|http://covid19.genenetwork.org/resource/(.*)", sequenceuri)
+ fastauri = "http://collections.lugli.arvadosapi.com/c=%s/sequence.fasta" % m.group(1)
+ metauri = "http://collections.lugli.arvadosapi.com/c=%s/metadata.yaml" % m.group(1)
locationuri=sample['geo']['value']
location=sample['geoname']['value']
date=sample['date']['value']
@@ -715,7 +747,18 @@ select distinct ?sample ?geoname ?date ?source ?geo ?sampletype ?institute ?sequ
institute=''
if 'institute' in sample:
institute=sample['institute']['value']
- return render_template('permalink.html',id=id,menu='',uri=f"http://covid19.genenetwork.org/resource/{id}",sequenceuri=sequenceuri,locationuri=locationuri,location=location,date=date,source=source,sampletype=sampletype,institute=institute,collectionuri=collectionuri,metauri=metauri)
+ return render_template('permalink.html',
+ id=id,
+ menu='',
+ uri=f"http://covid19.genenetwork.org/resource/{id}",
+ sequenceuri=fastauri,
+ locationuri=locationuri,
+ location=location,
+ date=date,
+ source=source,
+ sampletype=sampletype,
+ institute=institute,
+ metauri=metauri)
# http://covid19.genenetwork.org/location?label=http://www.wikidata.org/entity/Q114
# http://localhost:5067/location?label=http://www.wikidata.org/entity/Q114
diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css
index bc4f705..76a1755 100644
--- a/bh20simplewebuploader/static/main.css
+++ b/bh20simplewebuploader/static/main.css
@@ -506,3 +506,30 @@ div.status {
font-size: 16px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
+
+.flex-container {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: space-evenly;
+}
+
+#twitter-feed {
+ background-color: #f5f8fa;
+ max-height: 440px;
+ max-width: 500px;
+ overflow-y: auto;
+ padding: 20px;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+
+#twitter-feed ul {
+ list-style-type: none;
+}
+
+#twitter-feed ul li {
+ border-bottom: 2px solid white;
+ padding-bottom: 20px;
+}
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 89bc603..6cc0d9f 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -68,6 +68,12 @@ function fetchHTMLTable(apiEndPoint) {
htmlString="<table>"
for (var i=0; i<data.length;i++) {
let url = data[i]["key"];
+ continents = ["Q538", "Q48", "Q49", "Q18", "Q15", "Q27611" ];
+ node = url.split("/").pop();
+ console.log(continents.includes(node));
+ if (url.includes("wikidata") && !continents.includes(node)) {
+ url = "http://covid19.genenetwork.org/location?label="+url ;
+ }
let label = data[i]["label"];
htmlString=htmlString+"<tr><td><a href=\""+url+"\">"+label+"</a></td><td>"+data[i]["count"]+"<td></tr>"
}
diff --git a/bh20simplewebuploader/templates/blog.html b/bh20simplewebuploader/templates/blog.html
index 88ce4c3..fa08f5b 100644
--- a/bh20simplewebuploader/templates/blog.html
+++ b/bh20simplewebuploader/templates/blog.html
@@ -9,12 +9,11 @@
{{ embed|safe }}
<hr>
- <h1>Other blog entries</h1>
+ <h1>Other documents</h1>
{% else %}
- {% include 'blurb.html' %}
- <h2>BLOG Entries:</h2>
+ <h2>Documents:</h2>
{% endif %}
<section class="blog-entries">
diff --git a/bh20simplewebuploader/templates/home.html b/bh20simplewebuploader/templates/home.html
index 77d2fb6..be948f6 100644
--- a/bh20simplewebuploader/templates/home.html
+++ b/bh20simplewebuploader/templates/home.html
@@ -22,9 +22,27 @@
or <a href="/apidoc">REST API</a>. For more
information see the <a href="/about">FAQ!</a>.
</p>
- <section id="map_view" class="map">
- <div id="mapid"></div>
- </section>
+
+ <section class="flex-container">
+ <div id="map_view" class="map">
+ <div id="mapid"></div>
+ </div>
+ <div id="twitter-feed">
+ <ul>
+ {% for tweet in tweets|sort(reverse=true, attribute="timeposted")%}
+ <li>
+ <p class="tweet">
+ {{ tweet.tweet|urlize(40, target="_blank") }} <br/>
+ by {{ tweet.author }}
+ </p>
+ <small class="timeposted">
+ {{ tweet.timeposted }}
+ </small>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+ </section>
<a href="https://projectredcap.org/"><img class="img-right" src="static/image/REDCap.png" /></a>
<p>
@@ -73,10 +91,11 @@
URI's</a>
for <a href="https://en.wikipedia.org/wiki/Wikipedia:Disambiguation">disambiguation</a>
and machine readable metadata. For examples of
- use, see the <a href="/blog">BLOG</a>.
+ use, see the <a href="/blog">docs</a>.
</p>
</div>
- </section>
+ </section>
+
{% include 'footer.html' %}
diff --git a/bh20simplewebuploader/templates/menu.html b/bh20simplewebuploader/templates/menu.html
index 5d5fdc8..8e6ef52 100644
--- a/bh20simplewebuploader/templates/menu.html
+++ b/bh20simplewebuploader/templates/menu.html
@@ -6,7 +6,7 @@
<a href="/status" class="{{ 'active' if menu=='STATUS' }}">STATUS</a>
<a href="/demo" class="{{ 'active' if menu=='DEMO' }}">DEMO</a>
<a href="/export" class="{{ 'active' if menu=='EXPORT' }}">EXPORT</a>
- <a href="/blog" class="{{ 'active' if menu=='BLOG' }}">BLOG</a>
+ <a href="/blog" class="{{ 'active' if menu=='BLOG' }}">DOCS</a>
<a href="/about" class="{{ 'active' if menu=='ABOUT' }}">ABOUT</a>
<a href="/contact" class="{{ 'active' if menu=='CONTACT' }}">CONTACT</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
diff --git a/bh20simplewebuploader/templates/resource.html b/bh20simplewebuploader/templates/resource.html
index fc52f13..4c50fb9 100644
--- a/bh20simplewebuploader/templates/resource.html
+++ b/bh20simplewebuploader/templates/resource.html
@@ -10,8 +10,8 @@
<p><a href="https://workbench.lugli.arvadosapi.com/projects/lugli-j7d0g-5ct8p1i1wrgyjvp#Data_collections">All sequences project</a></p>
<p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/relabeledSeqs.sorted_by_quality_and_len.fasta">All sequences (FASTA) relabled and deduplicated</a></p>
<p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/mergedmetadata.ttl">Metadata (RDF) for all sequences</a></p>
- <p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/relabeledSeqs.sorted_by_quality_and_len.g6.gfa">All sequences in Graphical Fragment Assembly (GFA)</a> - <a href="https://github.com/GFA-spec/GFA-spec">More about GFA</a></p>
- <p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/relabeledSeqs.sorted_by_quality_and_len.g6.unchop.sorted.odgi">All sequences in Optimized Dynamic Genome/Graph Implementation (ODGI)</a> - <a href="https://github.com/vgteam/odgi">More about ODGI</a></p>
+ <!-- <p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/relabeledSeqs.sorted_by_quality_and_len.g6.gfa">All sequences in Graphical Fragment Assembly (GFA)</a> - <a href="https://github.com/GFA-spec/GFA-spec">More about GFA</a></p> -->
+ <!-- <p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/relabeledSeqs.sorted_by_quality_and_len.g6.unchop.sorted.odgi">All sequences in Optimized Dynamic Genome/Graph Implementation (ODGI)</a> - <a href="https://github.com/vgteam/odgi">More about ODGI</a></p> -->
<!-- <p><a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca/relabeledSeqs_dedup_relabeledSeqs_dedup.ttl.xz">All sequences in RDF using spodgi</a> - <a href="https://github.com/pangenome/spodgi">More about spodgi</a></p> -->