aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2020-10-28 11:12:51 +0000
committerPjotr Prins2020-10-28 11:12:51 +0000
commit2e7ff0e040a011e4bc3aae2c2816c7f3f4ed875d (patch)
tree872c853d38c05b9457584e1b03d3bf73aaa26aa8
parente8e150c85414f67e9f15dfdcd04bcbe2369ac44f (diff)
downloadbh20-seq-resource-2e7ff0e040a011e4bc3aae2c2816c7f3f4ed875d.tar.gz
bh20-seq-resource-2e7ff0e040a011e4bc3aae2c2816c7f3f4ed875d.tar.lz
bh20-seq-resource-2e7ff0e040a011e4bc3aae2c2816c7f3f4ed875d.zip
Adding more metadata to resource uri
-rw-r--r--bh20simplewebuploader/main.py35
-rw-r--r--bh20simplewebuploader/templates/permalink.html30
2 files changed, 55 insertions, 10 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 37f4590..4ec3251 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -670,21 +670,24 @@ sparqlURL='http://sparql.genenetwork.org/sparql/'
##
# Example http://host/resource/MT326090.1
+# Example http://host/resource/SRR11621868
@app.route('/resource/<id>')
def resource(id):
"""Get a COVID19 resource using identifier"""
- query="""
+ 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
-{
- ?sample sio:SIO_000115 "MT326090.1" .
+select distinct ?sample ?geoname ?date ?source ?geo ?sampletype ?institute ?sequenceuri
+{{
+ ?sample sio:SIO_000115 "{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 .
- OPTIONAL {?sample <http://edamontology.org/data_2091> ?source }
- OPTIONAL {?sample <http://purl.obolibrary.org/obo/OBI_0001479> ?sampletype }
-}
+ OPTIONAL {{ ?sample <http://edamontology.org/data_2091> ?source }}
+ OPTIONAL {{ ?sample <http://purl.obolibrary.org/obo/OBI_0001479> ?sampletype }}
+ OPTIONAL {{ ?sample <http://purl.obolibrary.org/obo/NCIT_C41206> ?institute }}
+}}
"""
payload = {'query': query, 'format': 'json'}
r = requests.get(sparqlURL, params=payload)
@@ -694,12 +697,24 @@ select distinct ?sample ?geoname ?date ?source ?geo ?sampletype
logging.info(sample)
logging.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
# return jsonify({'sequences': int(result[0]["num"]["value"])})
+ sequenceuri=sample['sequenceuri']['value']
+ collectionuri=sequenceuri.split('sequence.fasta')[0]
+ metauri=collectionuri+'metadata.yaml'
locationuri=sample['geo']['value']
location=sample['geoname']['value']
date=sample['date']['value']
- source=sample['source']['value']
- sampletype=sample['sampletype']['value']
- return render_template('permalink.html',id=id,menu='',uri=f"http://covid19.genenetwork.org/resource/{id}",locationuri=locationuri,location=location,date=date,source=source,sampletype=sampletype)
+ if date == '1970-01-01':
+ date = ''
+ source=''
+ if 'source' in sample:
+ source=sample['source']['value']
+ sampletype=''
+ if 'sampletype' in sample:
+ sampletype=sample['sampletype']['value']
+ 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)
## Dynamic API functions starting here
## This is quick and dirty for now, just to get something out and demonstrate the queries
diff --git a/bh20simplewebuploader/templates/permalink.html b/bh20simplewebuploader/templates/permalink.html
index f75c21e..abf6b1e 100644
--- a/bh20simplewebuploader/templates/permalink.html
+++ b/bh20simplewebuploader/templates/permalink.html
@@ -59,6 +59,16 @@
<div class="blog-table-body">
<div class="blog-table-row">
<div class="blog-table-cell">
+ Institute
+ </div>
+ <div class="blog-table-cell">
+ {{ institute }}
+ </div>
+ </div>
+ </div>
+ <div class="blog-table-body">
+ <div class="blog-table-row">
+ <div class="blog-table-cell">
Sample type
</div>
<div class="blog-table-cell">
@@ -69,6 +79,26 @@
<div class="blog-table-body">
<div class="blog-table-row">
<div class="blog-table-cell">
+ Sequence
+ </div>
+ <div class="blog-table-cell">
+ <a href="{{ sequenceuri }}">{{sequenceuri}}</a>
+ </div>
+ </div>
+ </div>
+ <div class="blog-table-body">
+ <div class="blog-table-row">
+ <div class="blog-table-cell">
+ Metadata
+ </div>
+ <div class="blog-table-cell">
+ <a href="{{ metauri }}">{{metauri}}</a>
+ </div>
+ </div>
+ </div>
+ <div class="blog-table-body">
+ <div class="blog-table-row">
+ <div class="blog-table-cell">
Source
</div>
<div class="blog-table-cell">