diff options
Diffstat (limited to 'qc_app')
-rw-r--r-- | qc_app/db/datasets.py | 22 | ||||
-rw-r--r-- | qc_app/templates/rqtl2/summary-info.html | 11 | ||||
-rw-r--r-- | qc_app/upload/rqtl2.py | 35 |
3 files changed, 35 insertions, 33 deletions
diff --git a/qc_app/db/datasets.py b/qc_app/db/datasets.py index 448db18..b56dcf5 100644 --- a/qc_app/db/datasets.py +++ b/qc_app/db/datasets.py @@ -18,12 +18,12 @@ def geno_datasets_by_species_and_population( {"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: +def geno_dataset_by_id(conn: mdb.Connection, dataset_id) -> Optional[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()) + cursor.execute("SELECT * FROM GenoFreeze WHERE Id=%s", (dataset_id,)) + _dataset = cursor.fetchone() + return dict(_dataset) if bool(_dataset) else None def probeset_studies_by_species_and_population( conn: mdb.Connection, @@ -46,12 +46,12 @@ def probeset_datasets_by_study(conn: mdb.Connection, (studyid,)) return tuple(dict(row) for row in cursor.fetchall()) -def probeset_study_by_id(conn: mdb.Connection, studyid: int) -> dict: +def probeset_study_by_id(conn: mdb.Connection, studyid) -> Optional[dict]: """Retrieve ProbeSet study by ID""" with conn.cursor(cursorclass=DictCursor) as cursor: - cursor.execute("SELECT * FROM ProbeFreeze WHERE Id=%s", - (studyid,)) - return dict(cursor.fetchone()) + cursor.execute("SELECT * FROM ProbeFreeze WHERE Id=%s", (studyid,)) + _study = cursor.fetchone() + return dict(_study) if bool(_study) else None def probeset_create_study(conn: mdb.Connection,#pylint: disable=[too-many-arguments] populationid: int, @@ -120,12 +120,10 @@ def probeset_create_dataset(conn: mdb.Connection,#pylint: disable=[too-many-argu dataset) return {**dataset, "datasetid": cursor.lastrowid} -def probeset_dataset_by_id( - conn: mdb.Connection, datasetid: int) -> Optional[dict]: +def probeset_dataset_by_id(conn: mdb.Connection, datasetid) -> Optional[dict]: """Fetch a ProbeSet dataset by its ID""" with conn.cursor(cursorclass=DictCursor) as cursor: - cursor.execute("SELECT * FROM ProbeSetFreeze WHERE Id=%s", - (datasetid,)) + cursor.execute("SELECT * FROM ProbeSetFreeze WHERE Id=%s", (datasetid,)) result = cursor.fetchone() if bool(result): return dict(result) diff --git a/qc_app/templates/rqtl2/summary-info.html b/qc_app/templates/rqtl2/summary-info.html index 3882c9c..9a9b6dd 100644 --- a/qc_app/templates/rqtl2/summary-info.html +++ b/qc_app/templates/rqtl2/summary-info.html @@ -19,14 +19,25 @@ <dt>Population</dt> <dd>{{population.InbredSetName}}</dd> + {%if geno_dataset%} <dt>Genotype Dataset</dt> <dd>{{geno_dataset.Name}} ({{geno_dataset.FullName}})</dd> + {%endif%} + {%if tissue%} + <dt>Tissue</dt> + <dd>{{tissue.TissueName}} ({{tissue.Name}}, {{tissue.Short_Name}})</dd> + {%endif%} + + {%if probe_study%} <dt>ProbeSet Study</dt> <dd>{{probe_study.Name}} ({{probe_study.FullName}})</dd> + {%endif%} + {%if probe_dataset%} <dt>ProbeSet Dataset</dt> <dd>{{probe_dataset.Name2}} ({{probe_dataset.FullName}})</dd> + {%endif%} </dl> <form id="frm:confirm-rqtl2bundle-details" diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index bf392a9..8c80ef3 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -525,7 +525,7 @@ def create_geno_dataset(species_id: int, population_id: int): return with_errors(__thunk__, partial(check_species, conn=conn), - partial(check_population, conn=conn), + partial(check_population, conn=conn, species_id=species_id), partial(check_r_qtl2_bundle, species_id=species_id, population_id=population_id)) @@ -765,6 +765,8 @@ def create_probeset_dataset(species_id: int, population_id: int):#pylint: disabl flash("Dataset full name not provided!", errorclasses) return summary_page + tissue = tissue_by_id(conn, form.get("tissueid", "").strip()) + study = probeset_study_by_id(conn, int(form["probe-study-id"])) if not bool(study): flash("Invalid ProbeSet study provided!", errorclasses) @@ -806,6 +808,7 @@ def create_probeset_dataset(species_id: int, population_id: int):#pylint: disabl geno_dataset=geno_dataset_by_id( conn, int(request.form["geno-dataset-id"])), + tissue=tissue, study=study, avgmethod=avgmethod, dataset=dset) @@ -846,6 +849,9 @@ 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) + + geno_dataset = geno_dataset_by_id( + conn,form.get("geno-dataset-id", "").strip()) if "geno" in cdata and not bool(form.get("geno-dataset-id")): return render_template( "rqtl2/select-geno-dataset.html", @@ -854,21 +860,6 @@ def select_dataset_info(species_id: int, population_id: int): rqtl2_bundle_file=thefile.name, datasets=geno_datasets_by_species_and_population( conn, species_id, population_id)) - geno_dataset = geno_dataset_by_id(conn, int(form["geno-dataset-id"])) - - if "pheno" in cdata and not bool(form.get("probe-study-id")): - tissue = tissue_by_id(conn, form.get("tissueid", "").strip()) - if not bool(tissue): - return render_template( - "rqtl2/select-tissue.html", - species=species, - population=population, - rqtl2_bundle_file=thefile.name, - geno_dataset=geno_dataset, - studies=probeset_studies_by_species_and_population( - conn, species_id, population_id), - platforms=platforms_by_species(conn, species_id), - tissues=all_tissues(conn)) tissue = tissue_by_id(conn, form.get("tissueid", "").strip()) if "pheno" in cdata and not bool(tissue): @@ -883,6 +874,9 @@ def select_dataset_info(species_id: int, population_id: int): platforms=platforms_by_species(conn, species_id), tissues=all_tissues(conn)) + probeset_study = probeset_study_by_id( + conn, form.get("probe-study-id", "").strip()) + if "pheno" in cdata and not bool(probeset_study): return render_template( "rqtl2/select-probeset-study-id.html", species=species, @@ -896,7 +890,9 @@ def select_dataset_info(species_id: int, population_id: int): probeset_study = probeset_study_by_id( conn, int(form["probe-study-id"])) - if "pheno" in cdata and not bool(form.get("probe-dataset-id")): + probeset_dataset = probeset_dataset_by_id( + conn, form.get("probe-dataset-id", "").strip()) + if "pheno" in cdata and not bool(probeset_dataset): return render_template( "rqtl2/select-probeset-dataset.html", species=species, @@ -908,16 +904,13 @@ def select_dataset_info(species_id: int, population_id: int): datasets=probeset_datasets_by_study( conn, int(form["probe-study-id"])), avgmethods=averaging_methods(conn)) - probeset_study = probeset_study_by_id( - conn, int(form["probe-study-id"])) - probeset_dataset = probeset_dataset_by_id( - conn, int(form["probe-dataset-id"])) return render_template("rqtl2/summary-info.html", species=species, population=population, rqtl2_bundle_file=thefile.name, geno_dataset=geno_dataset, + tissue=tissue, probe_study=probeset_study, probe_dataset=probeset_dataset) |