aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-05 13:08:38 +0300
committerFrederick Muriuki Muriithi2024-01-05 13:10:56 +0300
commit58a214a4a9be5fb219a798b62cdbf43d72280c74 (patch)
tree1ab9beaa142a4887e44aa6fe09e1206a959b024a /qc_app
parent6200a60eb6f04a5d50bfe0ad366674dc49a08119 (diff)
downloadgn-uploader-58a214a4a9be5fb219a798b62cdbf43d72280c74.tar.gz
Initialise R/qtl2 bundle upload path
Initialise the upload path for R/qtl2 bundles. This commit adds UI that allows the user to select from existing species, before proceeding to the next stage.
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/__init__.py2
-rw-r--r--qc_app/templates/base.html2
-rw-r--r--qc_app/templates/rqtl2/index.html34
-rw-r--r--qc_app/upload/__init__.py7
-rw-r--r--qc_app/upload/rqtl2.py31
5 files changed, 75 insertions, 1 deletions
diff --git a/qc_app/__init__.py b/qc_app/__init__.py
index f2001ab..1215954 100644
--- a/qc_app/__init__.py
+++ b/qc_app/__init__.py
@@ -5,6 +5,7 @@ import os
from flask import Flask
from .entry import entrybp
+from .upload import upload
from .parse import parsebp
from .samples import samples
from .dbinsert import dbinsertbp
@@ -30,6 +31,7 @@ def create_app(instance_dir):
# setup blueprints
app.register_blueprint(entrybp, url_prefix="/")
app.register_blueprint(parsebp, url_prefix="/parse")
+ app.register_blueprint(upload, url_prefix="/upload")
app.register_blueprint(dbinsertbp, url_prefix="/dbinsert")
app.register_blueprint(samples, url_prefix="/samples")
diff --git a/qc_app/templates/base.html b/qc_app/templates/base.html
index 0cc970c..3b701bc 100644
--- a/qc_app/templates/base.html
+++ b/qc_app/templates/base.html
@@ -11,7 +11,7 @@
<link rel="stylesheet" type="text/css" href="/static/css/styles.css" />
{%block css%}{%endblock%}
- <link rel="icon" type="image/png" sizes="64x64"
+ <link rel="shortcut icon" type="image/png" sizes="64x64"
href="/static/images/CITGLogo.png" />
</head>
diff --git a/qc_app/templates/rqtl2/index.html b/qc_app/templates/rqtl2/index.html
new file mode 100644
index 0000000..24f19fa
--- /dev/null
+++ b/qc_app/templates/rqtl2/index.html
@@ -0,0 +1,34 @@
+{%extends "base.html"%}
+{%from "flash_messages.html" import flash_messages%}
+
+{%block title%}Data Upload{%endblock%}
+
+{%block contents%}
+<h1 class="heading">R/qtl2 data upload</h1>
+
+<h2>R/qtl2 Upload</h2>
+
+<form method="POST" action="{{url_for('upload.rqtl2.select_species')}}"
+ id="frm-rqtl2-upload">
+ <legend class="heading">upload R/qtl2 bundle</legend>
+ {{flash_messages("error-rqtl2")}}
+ <fieldset>
+ <label for="select:species">Species</label>
+ <select id="select:species" name="species_id" required="required">
+ <option value="">Select species</option>
+ {%for spec in species%}
+ <option value="{{spec.SpeciesId}}">{{spec.MenuName}}</option>
+ {%endfor%}
+ </select>
+ <span class="form-input-help">
+ Data that you upload to the system should belong to a know species.
+ Here you can select the species that you wish to upload data for.
+ </span>
+ </fieldset>
+
+ <fieldset>
+ <input type="submit" value="submit" class="btn btn-main form-col-2" />
+ </fieldset>
+</form>
+
+{%endblock%}
diff --git a/qc_app/upload/__init__.py b/qc_app/upload/__init__.py
new file mode 100644
index 0000000..5f120d4
--- /dev/null
+++ b/qc_app/upload/__init__.py
@@ -0,0 +1,7 @@
+"""Package handling upload of files."""
+from flask import Blueprint
+
+from .rqtl2 import rqtl2
+
+upload = Blueprint("upload", __name__)
+upload.register_blueprint(rqtl2, url_prefix="/rqtl2")
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py
new file mode 100644
index 0000000..e54f141
--- /dev/null
+++ b/qc_app/upload/rqtl2.py
@@ -0,0 +1,31 @@
+"""Module to handle uploading of R/qtl2 bundles."""
+
+from flask import (
+ flash,
+ request,
+ url_for,
+ redirect,
+ Blueprint,
+ render_template)
+
+from qc_app.dbinsert import species as all_species
+from qc_app.dbinsert import species_by_id, groups_by_species
+from qc_app.db_utils import with_db_connection
+
+rqtl2 = Blueprint("rqtl2", __name__)
+
+@rqtl2.route("/", methods=["GET", "POST"])
+@rqtl2.route("/select-species", methods=["POST"])
+def select_species():
+ """Select the species."""
+ if request.method == "GET":
+ return render_template("rqtl2/index.html", species=all_species())
+
+ species_id = request.form.get("species_id")
+ species = with_db_connection(
+ lambda conn: species_by_id(conn, species_id))
+ if bool(species):
+ return redirect(url_for(
+ "upload.rqtl2.select_population", species_id=species_id))
+ flash("Invalid species or no species selected!", "alert-error error-rqtl2")
+ return redirect(url_for("upload.rqtl2.select_species"))