diff options
author | Frederick Muriuki Muriithi | 2024-01-17 05:38:29 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-01-17 05:39:10 +0300 |
commit | bf1c2ec1b16b50f419a349a54031baf85fcd4abd (patch) | |
tree | 3cd3bfdce0430f657457986becce7483a7172c16 /qc_app | |
parent | 4e3f6e51b92d9c56f77452bd4b723323a526bc52 (diff) | |
download | gn-uploader-bf1c2ec1b16b50f419a349a54031baf85fcd4abd.tar.gz |
UI: Initialise summary page.
Diffstat (limited to 'qc_app')
-rw-r--r-- | qc_app/db/datasets.py | 7 | ||||
-rw-r--r-- | qc_app/db/species.py | 10 | ||||
-rw-r--r-- | qc_app/templates/rqtl2/summary-info.html | 26 | ||||
-rw-r--r-- | qc_app/upload/rqtl2.py | 20 |
4 files changed, 51 insertions, 12 deletions
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%} +<h2 class="heading">Summary</h2> + +<div class="explainer"> + <p>This is the information you have provided to accompany the R/qtl2 bundle + you have uploaded. Please verify the information is correct before + proceeding.</p> +</div> + +<dl> + <dt>Species</dt> + <dd>{{species.SpeciesName}} ({{species.FullName}})</dd> + + <dt>Population</dt> + <dd>{{population.InbredSetName}}</dd> + + <dt>Genotype Dataset</dt> + <dd>{{geno_dataset.Name}} ({{geno_dataset.FullName}})</dd> +</dl> + +{%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/<int:species_id>/population/<int:population_id>" "/rqtl2-bundle/select-geno-dataset"), |