aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader
diff options
context:
space:
mode:
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r--bh20simplewebuploader/main.py21
-rw-r--r--bh20simplewebuploader/static/image/CWL-Logo-Header.pngbin0 -> 4771 bytes
-rw-r--r--bh20simplewebuploader/static/image/arvados-logo.pngbin0 -> 9514 bytes
-rw-r--r--bh20simplewebuploader/static/image/coronasmallcomp.gifbin0 -> 7335879 bytes
-rw-r--r--bh20simplewebuploader/static/image/covid19biohackathon.pngbin0 -> 21756 bytes
-rw-r--r--bh20simplewebuploader/templates/error.html5
-rw-r--r--bh20simplewebuploader/templates/form.html144
7 files changed, 139 insertions, 31 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index bfc7762..f5324a5 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -3,12 +3,18 @@ import tempfile
import shutil
import subprocess
import os
+import sys
import re
import string
import yaml
import urllib.request
from flask import Flask, request, redirect, send_file, send_from_directory, render_template
+import os.path
+
+if not os.path.isfile('bh20sequploader/mainx.py'):
+ print("WARNING: run FLASK from the root of the source repository!", file=sys.stderr)
+
app = Flask(__name__, static_url_path='/static', static_folder='static')
# Limit file upload size. We shouldn't be working with anything over 1 MB; these are small genomes.
@@ -126,6 +132,7 @@ def generate_form(schema):
return list(walk_fields(root_name))
+
# At startup, we need to load the current metadata schema so we can make a form for it
METADATA_SCHEMA = yaml.safe_load(urllib.request.urlopen('https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml'))
FORM_ITEMS = generate_form(METADATA_SCHEMA)
@@ -184,15 +191,17 @@ def receive_files():
# We're going to work in one directory per request
dest_dir = tempfile.mkdtemp()
+ # The uploader will happily accept a FASTQ with this name
fasta_dest = os.path.join(dest_dir, 'fasta.fa')
metadata_dest = os.path.join(dest_dir, 'metadata.json')
try:
if 'fasta' not in request.files:
return (render_template('error.html',
- error_message="You did not include a FASTA file."), 403)
+ error_message="You did not include a FASTA or FASTQ file."), 403)
try:
with open(fasta_dest, 'wb') as out_stream:
- copy_with_limit(request.files.get('fasta').stream, out_stream)
+ # Use a plausible file size limit for a little FASTQ
+ copy_with_limit(request.files.get('fasta').stream, out_stream, limit=50*1024*1024)
except FileTooBigError as e:
# Delegate to the 413 error handler
return handle_large_file(e)
@@ -247,12 +256,16 @@ def receive_files():
error_message="You did not include metadata."), 403)
# Try and upload files to Arvados using the sequence uploader CLI
- result = subprocess.run(['bh20-seq-uploader', fasta_dest, metadata_dest],
+
+ cmd = ['python3','bh20sequploader/main.py', fasta_dest, metadata_dest]
+ print(" ".join(cmd),file=sys.stderr)
+ result = subprocess.run(cmd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0:
# It didn't work. Complain.
- error_message="Upload failed. Uploader returned {} and said:\n{}".format(result.returncode, result.stderr)
+ error_message="Uploader returned value {} and said:".format(result.returncode) + str(result.stderr.decode('utf-8'))
+ print(error_message, file=sys.stderr)
return (render_template('error.html', error_message=error_message), 403)
else:
# It worked. Say so.
diff --git a/bh20simplewebuploader/static/image/CWL-Logo-Header.png b/bh20simplewebuploader/static/image/CWL-Logo-Header.png
new file mode 100644
index 0000000..86855b4
--- /dev/null
+++ b/bh20simplewebuploader/static/image/CWL-Logo-Header.png
Binary files differ
diff --git a/bh20simplewebuploader/static/image/arvados-logo.png b/bh20simplewebuploader/static/image/arvados-logo.png
new file mode 100644
index 0000000..fdbd88e
--- /dev/null
+++ b/bh20simplewebuploader/static/image/arvados-logo.png
Binary files differ
diff --git a/bh20simplewebuploader/static/image/coronasmallcomp.gif b/bh20simplewebuploader/static/image/coronasmallcomp.gif
new file mode 100644
index 0000000..7a16637
--- /dev/null
+++ b/bh20simplewebuploader/static/image/coronasmallcomp.gif
Binary files differ
diff --git a/bh20simplewebuploader/static/image/covid19biohackathon.png b/bh20simplewebuploader/static/image/covid19biohackathon.png
new file mode 100644
index 0000000..7a744b6
--- /dev/null
+++ b/bh20simplewebuploader/static/image/covid19biohackathon.png
Binary files differ
diff --git a/bh20simplewebuploader/templates/error.html b/bh20simplewebuploader/templates/error.html
index c2ab0a4..b1d9402 100644
--- a/bh20simplewebuploader/templates/error.html
+++ b/bh20simplewebuploader/templates/error.html
@@ -9,7 +9,10 @@
<h1>Upload Failed</h1>
<hr>
<p>
- Your upload has failed. {{error_message}}
+ Your upload has failed.
+ <pre>
+ {{error_message|safe}}
+ </pre>
</p>
<p>
<a href="/">Click here to try again.</a>
diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html
index d960bb2..df66e8c 100644
--- a/bh20simplewebuploader/templates/form.html
+++ b/bh20simplewebuploader/templates/form.html
@@ -7,10 +7,12 @@
body {
color: #101010;
+ background-color: #F9EDE1;
}
- h1, h4 {
+ h1, h2, h3, h4 {
font-family: 'Roboto Slab', serif;
+ color: darkblue;
}
h1 {
@@ -21,8 +23,19 @@
color: #505050;
font-style: italic;
}
+ .header {
+ background-color: white;
+ margin: 0 auto;
+ padding: 20px;
+ text-align: center;
+ height: 150px;
+ }
- p, form {
+ .logo {
+ float: right;
+ }
+
+ p, form, .about, .footer {
font-family: 'Raleway', sans-serif;
line-height: 1.5;
}
@@ -36,9 +49,23 @@
}
.intro {
+ background-color: lightgrey;
+ margin: 0 auto;
+ padding: 20px;
+ }
+
+ .about {
+ background-color: lightgrey;
margin: 0 auto;
padding: 20px;
}
+ .footer {
+ background-color: white;
+ margin: 0 auto;
+ }
+
+ span.dropt {border-bottom: thin dotted; background: #ffeedd;}
+ span.dropt:hover {text-decoration: none; background: #ffffff; z-index: 6; }
.grid-container {
display: grid;
@@ -59,10 +86,16 @@
}
.fasta-file-select {
+ padding: 1em;
grid-area: b;
}
.metadata {
+ padding: 1em;
+ grid-area: c;
+ }
+ .metadata_upload_form {
+ padding: 1em;
grid-area: c;
}
@@ -115,40 +148,65 @@
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@500&family=Roboto+Slab&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Simple Web Uploader for Public SARS-CoV-2 Sequence Resource</title>
+ <title>Web uploader for Public SARS-CoV-2 Sequence Resource</title>
</head>
<body>
- <h1>Simple Web Uploader for Public SARS-CoV-2 Sequence Resource</h1>
+ <section class="header">
+ <div class="logo"><a href="http://covid-19.genenetwork.org/"><img src="static/image/coronasmallcomp.gif" width="150" title="COVID-19 image by Tyler Morgan-Wall"></a></div>
+ <h1>Web uploader for Public SARS-CoV-2 Sequence Resource</h1>
+
+<small>Disabled until we got everything wired up</small>
+
+ </section>
<hr>
+
<section>
<form action="/submit" method="POST" enctype="multipart/form-data" id="main_form" class="grid-container">
- <p class="intro">
- This tool can be used to upload sequenced genomes of SARS-CoV-2 samples to the <a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca">Public SARS-CoV-2 Sequence Resource</a>. Your uploaded sequence will automatically be processed and incorporated into the public pangenome.
- </p>
+ <p class="intro">
+ Upload your SARS-CoV-2 sequence (FASTA or FASTQ formats) with metadata (JSONLD) to the <a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca">public sequence resource</a>. The upload will trigger a
+ recompute with all available sequences into a Pangenome
+ available for
+ <a href="https://workbench.lugli.arvadosapi.com/collections/lugli-4zz18-z513nlpqm03hpca">download</a>!
+ Your uploaded sequence will automatically be processed
+ and incorporated into the public pangenome with
+ metadata using worklows from the High Performance Open Biology Lab defined <a href="https://github.com/hpobio-lab/viral-analysis/tree/master/cwl/pangenome-generate">here</a>. All data is published under
+ a <a href="https://creativecommons.org/licenses/by/4.0/">Creative
+ Commons 4.0 attribution license</a> (CC-BY-4.0). You
+ can take the published (GFA/RDF/FASTA) data and store it in
+ a triple store for further processing. We also plan to
+ combine identifiers with clinical data stored securely at <a href="https://redcap-covid19.elixir-luxembourg.org/redcap/">REDCap</a>.
+ A free command line version of the uploader can be
+ installed from <a href="https://github.com/arvados/bh20-seq-resource">source</a>.
+ </p>
+
<div class="fasta-file-select">
- <label for="fasta">Select FASTA file for assembled genome (max 1MB):</label>
+ <label for="fasta">Select FASTA file of assembled genome (max 50K), or FASTQ of reads (<span class="dropt" title="For a larger fastq file you'll need to use a CLI uploader">max 150MB<span style="width:500px;"></span></span>) : </label>
<br>
- <input type="file" id="fasta" name="fasta" accept=".fa,.fasta,.fna" required>
+ <input type="file" id="fasta" name="fasta" accept=".fa,.fasta,.fna,.fq" required>
<br>
+ <small>
+ Note that by uploading your data you automatically agree to a <a href="https://creativecommons.org/licenses/by/4.0/">CC-BY-4.0 license</a>. </small>
</div>
<div class="metadata">
- <label>Select metadata submission method:</label>
- <br>
- <input type="radio" id="metadata_upload" name="metadata_type" value="upload" onchange="setMode()" checked required>
- <label for="metadata_upload">Upload metadata file</label>
- <input type="radio" id="metadata_form" name="metadata_type" value="fill" onchange="setMode()" required>
- <label for="metadata_form">Fill in metadata manually</label>
- <br>
- </div>
+ <label>Select metadata submission method:</label>
+ <br>
+ <input type="radio" id="metadata_form" name="metadata_type" value="fill" onchange="setMode()" checked required>
+ <label for="metadata_form">Fill in metadata manually</label>
+ <input type="radio" id="metadata_upload" name="metadata_type" value="upload" onchange="setMode()" required>
+ <label for="metadata_upload">Upload metadata file</label>
+ <br>
+ <small>Make sure the metadata has submitter attribution details.</small>
- <div id="metadata_upload_form_spot">
+ <div id="metadata_upload_form_spot">
<div id="metadata_upload_form">
- <label for="metadata">Select JSON or YAML metadata file following <a href="https://github.com/arvados/bh20-seq-resource/blob/master/bh20sequploader/bh20seq-schema.yml" target="_blank">this schema</a> (<a href="https://github.com/arvados/bh20-seq-resource/blob/master/example/metadata.yaml" target="_blank">Example 1</a>, <a href="https://github.com/arvados/bh20-seq-resource/blob/master/example/minimal_example.yaml" target="_blank">Example 2</a>, max 1MB):</label>
- <br>
- <input type="file" id="metadata" name="metadata" accept=".json,.yml,.yaml" required>
- <br>
+ <br>
+ <label for="metadata">Select JSON or YAML metadata file following <a href="https://github.com/arvados/bh20-seq-resource/blob/master/bh20sequploader/bh20seq-schema.yml" target="_blank">this schema</a> and <a href="https://github.com/arvados/bh20-seq-resource/blob/master/example/metadata.yaml" target="_blank">example</a> (max 50K):</label>
+ <br>
+ <input type="file" id="metadata" name="metadata" accept=".json,.yml,.yaml" required>
+ <br>
</div>
+ </div>
</div>
<div id="metadata_fill_form_spot">
@@ -157,7 +215,7 @@
{% for record in fields %}
{% if 'heading' in record %}
- {% if loop.index > 1 %}
+ {% if loop.index > 1 and 2 < 3 %}
</div>
{% endif %}
<div class="record">
@@ -180,11 +238,45 @@
</div>
- <input class="submit" type="submit" value="Add to Pangenome">
+<input class="submit" type="submit" value="Add to Pangenome">
</form>
</section>
- <hr>
- <small><a href="https://github.com/adamnovak/bh20-simple-web-uploader">Source</a> &middot; Made for <a href="https://github.com/virtual-biohackathons/covid-19-bh20">COVID-19-BH20</a></small>
+<hr>
+<br>
+<div class="about">
+ <h3>ABOUT</h3>
+ <p>
+ This a public repository created at the COVID-19 BioHackathon
+ that has a low barrier to entry for uploading sequence data using
+ best practices. I.e., data is published with a creative commons
+ 4.0 (CC-4.0) license with metadata using state-of-the art
+ standards and, perhaps most importantly, providing standardized
+ workflows that get triggered on upload, so that results are
+ immediately available in standardized data formats. The repository
+ will be maintained and expanded for the duration of the
+ pandemic. To contribute data simply upload it! To contribute code
+ and/or workflows see
+ the <a href="https://github.com/arvados/bh20-seq-resource">project
+ repository</a>. For more information see the <a href="https://github.com/arvados/bh20-seq-resource/blob/master/paper/paper.md">paper</a> (WIP).
+ </p>
+ <br>
+</div>
+
+ <hr>
+<div class="footer">
+ <a href="https://arvados.org/"><img src="static/image/arvados-logo.png" align="top"></a>
+ <a href="https://www.commonwl.org/"><img src="static/image/CWL-Logo-Header.png" height="70"></a>
+
+ <a href="https://github.com/virtual-biohackathons/covid-19-bh20">
+ <img src="static/image/covid19biohackathon.png" align="right" height="70"></a>
+
+ <center>
+ <small><a href="https://github.com/arvados/bh20-seq-resource">Source code</a> &middot; Powered by <a href="https://www.commonwl.org/">Common Workflow Language</a> &amp; <a href="https://arvados.org/">Arvados</a>; Made for <a href="https://github.com/virtual-biohackathons/covid-19-bh20">COVID-19-BH20</a>
+ </small>
+ </center>
+
+
+</div>
<script type="text/javascript">
let uploadForm = document.getElementById('metadata_upload_form')