aboutsummaryrefslogtreecommitdiff
path: root/qc_app/upload/rqtl2.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/upload/rqtl2.py')
-rw-r--r--qc_app/upload/rqtl2.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py
index 146c301..7db005c 100644
--- a/qc_app/upload/rqtl2.py
+++ b/qc_app/upload/rqtl2.py
@@ -189,6 +189,15 @@ def check_errors(conn, *args, **kwargs) -> Optional[Response]:
pgsrc="error"),
code=307)
+ if ("geno-dataset" in args and
+ not bool(request.form.get("geno-dataset-id"))):
+ flash("No genotype dataset was provided!", "alert-error alert-rqtl2")
+ return redirect(url_for("upload.rqtl2.select_geno_dataset",
+ species_id=species_id,
+ population_id=population_id,
+ pgsrc="error"),
+ code=307)
+
return False
@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
@@ -208,7 +217,7 @@ def select_dataset_info(species_id: int, population_id: int):
thefile = fullpath(form["rqtl2_bundle_file"])
with ZipFile(str(thefile), "r") as zfile:
cdata = r_qtl2.control_data(zfile)
- if "geno" in cdata and not bool(form.get("geno_datasetid")):
+ if "geno" in cdata and not bool(form.get("geno-dataset-id")):
return render_template(
"rqtl2/select-geno-dataset.html",
species=species_by_id(conn, species_id),
@@ -225,7 +234,29 @@ def select_dataset_info(species_id: int, population_id: int):
methods=["POST"])
def select_geno_dataset(species_id: int, population_id: int) -> Response:
"""Select from existing geno datasets."""
- return "IMPLEMENT THIS!!!"
+ with database_connection(app.config["SQL_URI"]) as conn:
+ error = check_errors(
+ conn, "species", "population", "rqtl2_bundle_file", "geno-dataset")
+ if bool(error):
+ return error
+
+ geno_dset = geno_dataset_by_species_and_population(
+ conn, species_id, population_id)
+ if not bool(geno_dset):
+ flash("No genotype dataset was provided!",
+ "alert-error alert-rqtl2")
+ return redirect(url_for("upload.rqtl2.select_geno_dataset",
+ species_id=species_id,
+ population_id=population_id,
+ pgsrc="error"),
+ code=307)
+
+ flash("Genotype accepted", "alert-success alert-rqtl2")
+ return redirect(url_for("upload.rqtl2.select_dataset_info",
+ species_id=species_id,
+ population_id=population_id,
+ pgsrc="upload.rqtl2.select_geno_dataset"),
+ code=307)
@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
"/rqtl2-bundle/create-geno-dataset"),