about summary refs log tree commit diff
path: root/bh20simplewebuploader
diff options
context:
space:
mode:
authorPjotr Prins2020-07-19 11:30:28 +0100
committerPjotr Prins2020-07-19 11:30:28 +0100
commit20cbfb593e89b07d68e6c16106a24e79cea61329 (patch)
tree6f37a96a45a0d428ee157f9616096a04e681c656 /bh20simplewebuploader
parente4a89d13863517020bbe82293e52cea98418c983 (diff)
downloadbh20-seq-resource-20cbfb593e89b07d68e6c16106a24e79cea61329.tar.gz
bh20-seq-resource-20cbfb593e89b07d68e6c16106a24e79cea61329.tar.lz
bh20-seq-resource-20cbfb593e89b07d68e6c16106a24e79cea61329.zip
Moch XML output
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r--bh20simplewebuploader/main.py10
-rw-r--r--bh20simplewebuploader/static/main.js5
-rw-r--r--bh20simplewebuploader/templates/ebi-sample.xml68
-rw-r--r--bh20simplewebuploader/templates/export.html2
4 files changed, 81 insertions, 4 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index 673f913..d524efe 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -696,12 +696,13 @@ def search():
     query = """
     PREFIX pubseq: <http://biohackathon.org/bh20-seq-schema#MainSchema/>
     PREFIX sio: <http://semanticscience.org/resource/>
-    select distinct ?id ?seq
+    PREFIX edam: <http://edamontology.org/>
+    select distinct ?id ?seq ?info
     {
     ?sample sio:SIO_000115 "%s" .
     ?sample sio:SIO_000115 ?id .
     ?seq pubseq:sample ?sample .
-    ?sample ?p ?o .
+    ?sample edam:data_2091 ?info .
     } limit 100
     """ % s
     payload = {'query': query, 'format': 'json'}
@@ -711,6 +712,7 @@ def search():
     return jsonify([{
         'id': x['id']['value'],
         'seq': x['seq']['value'],
+        'info': x['info']['value'],
     } for x in result])
 
 @app.route('/api/getAllaccessions', methods=['GET'])
@@ -934,3 +936,7 @@ def getSEQbyLocationAndSpecimenSource():
     r = requests.get(baseURL, params=payload)
     result = r.json()['results']['bindings']
     return str(result)
+
+@app.route('/api/ebi-sample.xml', methods=['GET'])
+def ebi_sample():
+    return render_template('ebi-sample.xml')
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 208823a..deda6ec 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -18,10 +18,13 @@ function toDIVTable(rows) {
     else {
         html = '<div class="rTable">';
         rows.forEach(row => {
+            id = row['id'];
             seq = row['seq'];
+            info = row['info'];
             html += '<div class="rTableRow">';
-            html += cell(row['id']);
+            html += cell('<a href="'+info+'">'+id+'</a>');
             html += cell('<a href="'+seq+'">FASTA</a>');
+            html += cell('<a href="/api/ebi-sample.xml?id='+id+'">EBI/ENA export XML</a>');
             html += '</div>';
         });
         html += '</div>';
diff --git a/bh20simplewebuploader/templates/ebi-sample.xml b/bh20simplewebuploader/templates/ebi-sample.xml
new file mode 100644
index 0000000..694c471
--- /dev/null
+++ b/bh20simplewebuploader/templates/ebi-sample.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SAMPLE_SET>
+  <SAMPLE alias="PubSeqSam0001" center_name="PubSeq01">
+    <TITLE>human gastric microbiota, mucosal</TITLE>
+    <SAMPLE_NAME>
+      <TAXON_ID>1284369</TAXON_ID>
+      <SCIENTIFIC_NAME>stomach metagenome</SCIENTIFIC_NAME>
+      <COMMON_NAME></COMMON_NAME>
+    </SAMPLE_NAME>
+    <SAMPLE_ATTRIBUTES>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>investigation type</TAG>
+        <VALUE>mimarks-survey</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>sequencing method</TAG>
+        <VALUE>pyrosequencing</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>collection date</TAG>
+        <VALUE>2010</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>host body site</TAG>
+        <VALUE>Mucosa of stomach</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>human-associated environmental package</TAG>
+        <VALUE>human-associated</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>geographic location (latitude)</TAG>
+        <VALUE>1.81</VALUE>
+     <UNITS>DD</UNITS>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>geographic location (longitude)</TAG>
+        <VALUE>-78.76</VALUE>
+     <UNITS>DD</UNITS>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+     <TAG>geographic location (country and/or sea)</TAG>
+     <VALUE>Colombia</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>geographic location (region and locality)</TAG>
+        <VALUE>Tumaco</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>environment (biome)</TAG>
+        <VALUE>coast</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>environment (feature)</TAG>
+        <VALUE>human-associated habitat</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>environment (material)</TAG>
+        <VALUE>gastric biopsy</VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>ENA-CHECKLIST</TAG>
+        <VALUE>ERC000011</VALUE>
+      </SAMPLE_ATTRIBUTE>
+    </SAMPLE_ATTRIBUTES>
+  </SAMPLE>
+</SAMPLE_SET>
+
diff --git a/bh20simplewebuploader/templates/export.html b/bh20simplewebuploader/templates/export.html
index 1f0d9b7..aaceac9 100644
--- a/bh20simplewebuploader/templates/export.html
+++ b/bh20simplewebuploader/templates/export.html
@@ -31,7 +31,7 @@
     </p>
 
     <div class="search">
-      <input id="search-input" type="search" placeholder="e.g. MT246484" required>
+      <input id="search-input" type="search" placeholder="e.g. MT326090.1" required>
       <button class="button search-button" type="submit" onclick="searchGlobaltoDIVTable()">
         <span class="icon ion-search">
           <span class="sr-only">Search</span>