From bf1c2ec1b16b50f419a349a54031baf85fcd4abd Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 17 Jan 2024 05:38:29 +0300 Subject: UI: Initialise summary page. --- qc_app/db/datasets.py | 7 +++++++ qc_app/db/species.py | 10 ++++------ qc_app/templates/rqtl2/summary-info.html | 26 ++++++++++++++++++++++++++ qc_app/upload/rqtl2.py | 20 ++++++++++++++------ 4 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 qc_app/templates/rqtl2/summary-info.html diff --git a/qc_app/db/datasets.py b/qc_app/db/datasets.py index 3a27706..8122cfa 100644 --- a/qc_app/db/datasets.py +++ b/qc_app/db/datasets.py @@ -14,3 +14,10 @@ def geno_dataset_by_species_and_population( "WHERE iset.SpeciesId=%(sid)s AND iset.InbredSetId=%(pid)s", {"sid": speciesid, "pid": populationid}) return tuple(dict(row) for row in cursor.fetchall()) + +def geno_dataset_by_id(conn: mdb.Connection, dataset_id: int) -> dict: + """Retrieve genotype dataset by ID""" + with conn.cursor(cursorclass=DictCursor) as cursor: + cursor.execute("SELECT * FROM GenoFreeze WHERE Id=%s", + (dataset_id,)) + return dict(cursor.fetchone()) diff --git a/qc_app/db/species.py b/qc_app/db/species.py index 7006d15..653e59b 100644 --- a/qc_app/db/species.py +++ b/qc_app/db/species.py @@ -6,8 +6,8 @@ def species(conn: mdb.Connection) -> tuple: "Retrieve the species from the database." with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( - "SELECT SpeciesId, SpeciesName, LOWER(Name) AS Name, MenuName " - "FROM Species") + "SELECT SpeciesId, SpeciesName, LOWER(Name) AS Name, MenuName, " + "FullName FROM Species") return tuple(cursor.fetchall()) return tuple() @@ -16,9 +16,7 @@ def species_by_id(conn: mdb.Connection, speciesid) -> dict: "Retrieve the species from the database by id." with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( - ( - "SELECT " - "SpeciesId, SpeciesName, LOWER(Name) AS Name, MenuName " - "FROM Species WHERE SpeciesId=%s"), + "SELECT SpeciesId, SpeciesName, LOWER(Name) AS Name, MenuName, " + "FullName FROM Species WHERE SpeciesId=%s", (speciesid,)) return cursor.fetchone() diff --git a/qc_app/templates/rqtl2/summary-info.html b/qc_app/templates/rqtl2/summary-info.html new file mode 100644 index 0000000..c3a2ac0 --- /dev/null +++ b/qc_app/templates/rqtl2/summary-info.html @@ -0,0 +1,26 @@ +{%extends "base.html"%} +{%from "flash_messages.html" import flash_messages%} + +{%block title%}Upload R/qtl2 Bundle{%endblock%} + +{%block contents%} +

Summary

+ +
+

This is the information you have provided to accompany the R/qtl2 bundle + you have uploaded. Please verify the information is correct before + proceeding.

+
+ +
+
Species
+
{{species.SpeciesName}} ({{species.FullName}})
+ +
Population
+
{{population.InbredSetName}}
+ +
Genotype Dataset
+
{{geno_dataset.Name}} ({{geno_dataset.FullName}})
+
+ +{%endblock%} diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 7db005c..9bed4f1 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -23,8 +23,9 @@ from qc_app.db import ( species_by_id, save_population, populations_by_species, - population_by_species_and_id, - geno_dataset_by_species_and_population) + population_by_species_and_id,) +from qc_app.db.datasets import ( + geno_dataset_by_id, geno_dataset_by_species_and_population) rqtl2 = Blueprint("rqtl2", __name__) @@ -214,20 +215,27 @@ def select_dataset_info(species_id: int, population_id: int): if bool(error_page): return error_page + species = species_by_id(conn, species_id) + population = population_by_species_and_id( + conn, species_id, population_id) 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-dataset-id")): return render_template( "rqtl2/select-geno-dataset.html", - species=species_by_id(conn, species_id), - population=population_by_species_and_id( - conn, species_id, population_id), + species=species, + population=population, rqtl2_bundle_file=thefile.name, datasets=geno_dataset_by_species_and_population( conn, species_id, population_id)) - return "All data points collected. Should proceed to launching the job." + geno_dataset = geno_dataset_by_id(conn, form["geno-dataset-id"]) + + return render_template("rqtl2/summary-info.html", + species=species, + population=population, + geno_dataset=geno_dataset) @rqtl2.route(("/upload/species//population/" "/rqtl2-bundle/select-geno-dataset"), -- cgit v1.2.3