aboutsummaryrefslogtreecommitdiff
path: root/qc_app/upload
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-18 14:43:00 +0300
committerFrederick Muriuki Muriithi2024-01-18 14:43:00 +0300
commitaf485aff7d25c1f5128586c550ca36debe24fd66 (patch)
tree16593e9e7a11cbd2ae2f5ab228f6620520a0b1b2 /qc_app/upload
parent0369fc21eaa54466bd64f3b12d1fe6a1dbc81de0 (diff)
downloadgn-uploader-af485aff7d25c1f5128586c550ca36debe24fd66.tar.gz
UI: Create new ProbeSet dataset.
Diffstat (limited to 'qc_app/upload')
-rw-r--r--qc_app/upload/rqtl2.py65
1 files changed, 63 insertions, 2 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py
index fc4e0e8..0b446ac 100644
--- a/qc_app/upload/rqtl2.py
+++ b/qc_app/upload/rqtl2.py
@@ -22,6 +22,7 @@ from qc_app.db_utils import with_db_connection, database_connection
from qc_app.db.tissues import all_tissues, tissue_by_id
from qc_app.db.platforms import platform_by_id, platforms_by_species
+from qc_app.db.averaging import averaging_methods, averaging_method_by_id
from qc_app.db import (
species_by_id,
save_population,
@@ -33,6 +34,7 @@ from qc_app.db.datasets import (
probeset_study_by_id,
probeset_create_study,
+ probeset_create_dataset,
probeset_datasets_by_study,
probeset_studies_by_species_and_population)
@@ -349,7 +351,7 @@ def select_probeset_dataset(species_id: int, population_id: int):
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")
+ flash("Invalid study selected!", "alert-error alert-rqtl2")
return summary_page
return summary_page
@@ -398,6 +400,64 @@ def create_probeset_study(species_id: int, population_id: int):
study=study)
@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
+ "/rqtl2-bundle/create-probeset-dataset"),
+ methods=["POST"])
+def create_probeset_dataset(species_id: int, population_id: int):#pylint: disable=[too-many-return-statements]
+ """Create a new 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")
+ if bool(error):
+ return error
+
+ form = request.form
+ summary_page = redirect(url_for("upload.rqtl2.select_dataset_info",
+ species_id=species_id,
+ population_id=population_id),
+ code=307)
+ if not bool(form.get("averageid")):
+ flash("Averaging method not selected!", "alert-error alert-rqtl2")
+ return summary_page
+ if not bool(form.get("datasetname")):
+ flash("Dataset name not provided!", "alert-error alert-rqtl2")
+ return summary_page
+ if not bool(form.get("datasetfullname")):
+ flash("Dataset full name not provided!", "alert-error alert-rqtl2")
+ return summary_page
+
+ study = probeset_study_by_id(conn, int(form["probe-study-id"]))
+ if not bool(study):
+ flash("Invalid ProbeSet study provided!", "alert-error alert-rqtl2")
+ return summary_page
+
+ avgmethod = averaging_method_by_id(conn, int(form["averageid"]))
+ if not bool(avgmethod):
+ flash("Invalid averaging method provided!", "alert-error alert-rqtl2")
+ return summary_page
+
+ dset = probeset_create_dataset(conn,
+ int(form["probe-study-id"]),
+ int(form["averageid"]),
+ form["datasetname"],
+ form["datasetfullname"],
+ form["datasetshortname"],
+ form["datasetpublic"] == "on",
+ form.get("datasetdatascale", "log2"))
+ return render_template(
+ "rqtl2/create-probe-dataset-success.html",
+ species=species_by_id(conn, species_id),
+ population=population_by_species_and_id(
+ conn, species_id, population_id),
+ rqtl2_bundle_file=request.form["rqtl2_bundle_file"],
+ geno_dataset=geno_dataset_by_id(
+ conn,
+ int(request.form["geno-dataset-id"])),
+ study=study,
+ avgmethod=avgmethod,
+ dataset=dset)
+
+@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
"/rqtl2-bundle/dataset-info"),
methods=["POST"])
def select_dataset_info(species_id: int, population_id: int):
@@ -450,7 +510,8 @@ def select_dataset_info(species_id: int, population_id: int):
geno_dataset=geno_dataset,
probe_study=probeset_study,
datasets=probeset_datasets_by_study(
- conn, int(form["probe-study-id"])))
+ conn, int(form["probe-study-id"])),
+ avgmethods=averaging_methods(conn))
return render_template("rqtl2/summary-info.html",
species=species,