aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-18 13:13:52 +0300
committerFrederick Muriuki Muriithi2024-01-18 13:13:52 +0300
commit0369fc21eaa54466bd64f3b12d1fe6a1dbc81de0 (patch)
tree949aa9417cc4ec25ca78d03b4978c92e05155335 /qc_app
parentcf8d133b110d87aed5cb6695711616625a6669fd (diff)
downloadgn-uploader-0369fc21eaa54466bd64f3b12d1fe6a1dbc81de0.tar.gz
UI: Select from existing ProbeSet datasets.
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/templates/rqtl2/select-probeset-dataset.html45
-rw-r--r--qc_app/upload/rqtl2.py44
2 files changed, 81 insertions, 8 deletions
diff --git a/qc_app/templates/rqtl2/select-probeset-dataset.html b/qc_app/templates/rqtl2/select-probeset-dataset.html
index c0c6401..8b9e5ed 100644
--- a/qc_app/templates/rqtl2/select-probeset-dataset.html
+++ b/qc_app/templates/rqtl2/select-probeset-dataset.html
@@ -1,5 +1,5 @@
{%extends "base.html"%}
-{%from "flash_messages.html" import flash_messages%}
+{%from "flash_messages.html" import flash_all_messages%}
{%block title%}Upload R/qtl2 Bundle{%endblock%}
@@ -8,10 +8,51 @@
<div class="explainer">
<p>The R/qtl2 bundle you uploaded contains (a) "<strong>pheno</strong>"
- file(s). This data needs to be organised under a dataset..</p>
+ file(s). This data needs to be organised under a dataset.</p>
<p>This page gives you the ability to do that.</p>
</div>
+{{flash_all_messages()}}
+
+<form method="POST"
+ action="{{url_for('upload.rqtl2.select_probeset_dataset',
+ species_id=species.SpeciesId, population_id=population.Id)}}"
+ id="frm:select-probeset-dataset">
+ <legend class="heading">Select from existing ProbeSet datasets</legend>
+
+ <input type="hidden" name="species_id" value="{{species.SpeciesId}}" />
+ <input type="hidden" name="population_id"
+ value="{{population.InbredSetId}}" />
+ <input type="hidden" name="rqtl2_bundle_file"
+ value="{{rqtl2_bundle_file}}" />
+ <input type="hidden" name="geno-dataset-id" value="{{geno_dataset.Id}}" />
+ <input type="hidden" name="probe-study-id" value="{{probe_study.Id}}" />
+
+ <fieldset>
+ <label for="select:probe-dataset">Dataset</label>
+ <select id="select:probe-dataset"
+ name="probe-dataset-id"
+ required="required"
+ {%if datasets | length == 0%}disabled="disabled"{%endif%}>
+ <option value="">Select a dataset</option>
+ {%for dataset in datasets%}
+ <option value={{dataset.Id}}>
+ {{dataset.Name}}
+ {%if dataset.FullName%}
+ -- ({{dataset.FullName}})
+ {%endif%}
+ </option>
+ {%endfor%}
+ </select>
+ </fieldset>
+
+ <fieldset>
+ <input type="submit"
+ value="select dataset"
+ class="btn btn-main form-col-2" />
+ </fieldset>
+</form>
+
<p style="color: red; font-weight: bold;">Under Construction</p>
{%endblock%}
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py
index 0d80776..fc4e0e8 100644
--- a/qc_app/upload/rqtl2.py
+++ b/qc_app/upload/rqtl2.py
@@ -172,7 +172,7 @@ def upload_rqtl2_bundle(species_id: int, population_id: int):
flash("".join(exc.args), "alert-error alert-rqtl2")
return this_page_with_errors
-def check_errors(conn, *args, **kwargs):
+def check_errors(conn, *args, **kwargs):#pylint: disable=[too-many-return-statements]
"""Check for select errors in the forms and return a page to redirect to."""
species_id = kwargs.get("species_id") or request.form.get("species_id")
population_id = (kwargs.get("population_id")
@@ -208,14 +208,21 @@ def check_errors(conn, *args, **kwargs):
pgsrc="error"),
code=307)
+ summary_page = redirect(url_for("upload.rqtl2.select_dataset_info",
+ species_id=species_id,
+ population_id=population_id,
+ pgsrc="error"),
+ code=307)
+
if ("probe-study-id" in args and
not bool(request.form.get("probe-study-id"))):
flash("No probeset study was selected!", "alert-error alert-rqtl2")
- return redirect(url_for("upload.rqtl2.select_probeset_study",
- species_id=species_id,
- population_id=population_id,
- pgsrc="error"),
- code=307)
+ return summary_page
+
+ if ("probe-dataset-id" in args and
+ not bool(request.form.get("probe-dataset-id"))):
+ flash("No probeset dataset was selected!", "alert-error alert-rqtl2")
+ return summary_page
return None
@@ -326,6 +333,28 @@ def select_probeset_study(species_id: int, population_id: int):
return summary_page
@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
+ "/rqtl2-bundle/select-probeset-dataset"),
+ methods=["POST"])
+def select_probeset_dataset(species_id: int, population_id: int):
+ """Select or create a probeset dataset."""
+ with database_connection(app.config["SQL_URI"]) as conn:
+ error = check_errors(
+ conn, "species", "population", "rqtl2_bundle_file", "geno-dataset",
+ "probe-study-id", "probe-dataset-id")
+ if bool(error):
+ return error
+
+ summary_page = redirect(url_for("upload.rqtl2.select_dataset_info",
+ species_id=species_id,
+ population_id=population_id),
+ code=307)
+ if not bool(probeset_study_by_id(conn, int(request.form["probe-study-id"]))):
+ flash("Invalid dataset selected!", "alert-error alert-rqtl2")
+ return summary_page
+
+ return summary_page
+
+@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
"/rqtl2-bundle/create-probeset-study"),
methods=["POST"])
def create_probeset_study(species_id: int, population_id: int):
@@ -409,6 +438,8 @@ def select_dataset_info(species_id: int, population_id: int):
conn, species_id, population_id),
platforms=platforms_by_species(conn, species_id),
tissues=all_tissues(conn))
+ probeset_study = probeset_study_by_id(
+ conn, int(form["probe-study-id"]))
if "pheno" in cdata and not bool(form.get("probe-dataset-id")):
return render_template(
@@ -417,6 +448,7 @@ def select_dataset_info(species_id: int, population_id: int):
population=population,
rqtl2_bundle_file=thefile.name,
geno_dataset=geno_dataset,
+ probe_study=probeset_study,
datasets=probeset_datasets_by_study(
conn, int(form["probe-study-id"])))