aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-07-08 10:39:19 +0300
committerFrederick Muriuki Muriithi2022-07-19 04:59:59 +0300
commit3038c5166aad408d7255f83668b78d635878d3d3 (patch)
treed9384464a1f3c92b50db747346e74cfbc8396119 /qc_app
parent7a3a54ec40fac9071a513487602957f8418f163e (diff)
downloadgn-uploader-3038c5166aad408d7255f83668b78d635878d3d3.tar.gz
Implement select study
Implement the select study UI
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/dbinsert.py36
-rw-r--r--qc_app/static/css/styles.css8
-rw-r--r--qc_app/static/css/two-column-with-separator.css27
-rw-r--r--qc_app/templates/select_platform.html2
-rw-r--r--qc_app/templates/select_study.html88
5 files changed, 158 insertions, 3 deletions
diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py
index ea47806..e506175 100644
--- a/qc_app/dbinsert.py
+++ b/qc_app/dbinsert.py
@@ -53,6 +53,23 @@ def genechips():
return {}
+def studies_by_species_and_platform(speciesid:int, genechipid:int) -> tuple:
+ "Retrieve the studies by the related species and gene platform"
+ with database_connection() as conn:
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ query = (
+ "SELECT Species.SpeciesId, ProbeFreeze.* "
+ "FROM Species INNER JOIN InbredSet "
+ "ON Species.SpeciesId=InbredSet.SpeciesId "
+ "INNER JOIN ProbeFreeze "
+ "ON InbredSet.InbredSetId=ProbeFreeze.InbredSetId "
+ "WHERE Species.SpeciesId = %s "
+ "AND ProbeFreeze.ChipId = %s")
+ cursor.execute(query, (speciesid, genechipid))
+ return tuple(cursor.fetchall())
+
+ return tuple()
+
@dbinsertbp.route("/platform", methods=["POST"])
def select_platform():
"Select the platform (GeneChipId) used for the data."
@@ -76,7 +93,24 @@ def select_platform():
@dbinsertbp.route("/study", methods=["POST"])
def select_study():
- return "Not implemented yet"
+ "View to select/create the study (ProbeFreeze) associated with the data."
+ form = request.form
+ try:
+ assert form.get("filename"), "filename"
+ assert form.get("filetype"), "filetype"
+ assert form.get("species"), "species"
+ assert form.get("genechipid"), "platform"
+
+ speciesid = form["species"]
+ genechipid = form["genechipid"]
+
+ the_studies = studies_by_species_and_platform(speciesid, genechipid)
+ return render_template(
+ "select_study.html", filename=form["filename"],
+ filetype=form["filetype"], species=speciesid, genechipid=genechipid,
+ studies=the_studies)
+ except AssertionError as aserr:
+ return render_error(f"Missing data: {aserr.args[0]}")
@dbinsertbp.route("/select-dataset", methods=["POST"])
def select_dataset():
diff --git a/qc_app/static/css/styles.css b/qc_app/static/css/styles.css
index d27952a..a42ffb0 100644
--- a/qc_app/static/css/styles.css
+++ b/qc_app/static/css/styles.css
@@ -117,10 +117,16 @@ fieldset {
.form-col-2 {
grid-column: 2 / 3;
- width: 20%;
}
input[disabled="true"],input[disabled="disabled"] {
border-color: #878787;
background-color: #A9A9A9;
}
+
+form legend {
+ padding-left: 3em;
+ text-transform: capitalize;
+ font-weight: bolder;
+ line-height: 2em;
+}
diff --git a/qc_app/static/css/two-column-with-separator.css b/qc_app/static/css/two-column-with-separator.css
new file mode 100644
index 0000000..b6efd46
--- /dev/null
+++ b/qc_app/static/css/two-column-with-separator.css
@@ -0,0 +1,27 @@
+.two-column-with-separator {
+ display: grid;
+ grid-template-columns: 9fr 1fr 9fr;
+}
+
+.two-col-sep-col1 {
+ grid-column: 1 / 2;
+}
+
+.two-col-sep-separator {
+ grid-column: 2 / 3;
+ text-align: center;
+ color: #FE3535;
+ font-weight: bolder;
+}
+
+.two-col-sep-col2 {
+ grid-column: 3 / 4;
+}
+
+.two-col-sep-col1, .two-col-sep-col2 {
+ border-style: solid;
+ border-color: #FE3535;
+ border-width: 1px;
+ border-radius: 2em;
+ padding: 2em 3em 2em 3em;
+}
diff --git a/qc_app/templates/select_platform.html b/qc_app/templates/select_platform.html
index f8db736..131003d 100644
--- a/qc_app/templates/select_platform.html
+++ b/qc_app/templates/select_platform.html
@@ -3,7 +3,7 @@
{%block title%}Select Dataset{%endblock%}
{%block contents%}
-<h1 class="heading">{{filename}}: select platform</h2>
+<h2 class="heading">{{filename}}: select platform</h2>
<form method="POST" action="{{url_for('dbinsert.select_study')}}"
id="select-platform-form" data-genechips="{{genechips_data}}">
diff --git a/qc_app/templates/select_study.html b/qc_app/templates/select_study.html
new file mode 100644
index 0000000..8d7a98b
--- /dev/null
+++ b/qc_app/templates/select_study.html
@@ -0,0 +1,88 @@
+{%extends "base.html"%}
+
+{%block title%}Select Dataset{%endblock%}
+
+{%block css%}
+<link rel="stylesheet" href="/static/css/two-column-with-separator.css" />
+{%endblock%}
+
+{%block contents%}
+<h2 class="heading">{{filename}}: select study</h2>
+
+<div class="two-column-with-separator">
+ <form method="POST" action="{{url_for('dbinsert.select_study')}}"
+ id="select-platform-form" data-genechips="{{genechips_data}}"
+ class="two-col-sep-col1">
+ <legend>Select from existing study</legend>
+ <input type="hidden" name="filename" value="{{filename}}" />
+ <input type="hidden" name="filetype" value="{{filetype}}" />
+ <input type="hidden" name="species" value="{{species}}" />
+ <input type="hidden" name="genechipid" value="{{genechipid}}" />
+
+ <fieldset>
+ <label for="study" class="form-col-1">study:</label>
+ <select id="study" name="studyid" class="form-col-2">
+ {%for study in studies:%}
+ <option value="{{study['ProbeFreezeId']}}">{{study["Name"]}}</option>
+ {%endfor%}
+ </select>
+ </fieldset>
+
+ <fieldset>
+ <input type="submit" value="submit selected study"
+ class="btn btn-main form-col-2"
+ {%if studies | length == 0:%}
+ disabled="disabled"
+ {%endif%} />
+ </fieldset>
+ </form>
+
+ <p class="two-col-sep-separator">OR</p>
+
+ <form method="POST" action="{{url_for('dbinsert.select_study')}}"
+ id="select-platform-form" data-genechips="{{genechips_data}}"
+ class="two-col-sep-col2">
+ <legend>Create new study</legend>
+ <input type="hidden" name="filename" value="{{filename}}" />
+ <input type="hidden" name="filetype" value="{{filetype}}" />
+ <input type="hidden" name="species" value="{{species}}" />
+ <input type="hidden" name="genechipid" value="{{genechipid}}" />
+
+ <fieldset>
+ <label for="studyname" class="form-col-1">name:</label>
+ <input type="text" id="studyname" name="studyname" class="form-col-2"
+ required="required" />
+ </fieldset>
+
+ <fieldset>
+ <label for="studyfullname" class="form-col-1">full name:</label>
+ <input type="text" id="studyfullname" name="studyfullname"
+ class="form-col-2" />
+ </fieldset>
+
+ <fieldset>
+ <label for="studyshortname" class="form-col-1">short name:</label>
+ <input type="text" id="studyshortname" name="studyshortname"
+ class="form-col-2" />
+ </fieldset>
+
+ <fieldset>
+ <label for="group" class="form-col-1">group:</label>
+ <select id="group" name="inbredsetid" class="form-col-2">
+ </select>
+ </fieldset>
+
+ <fieldset>
+ <label for="tissue" class="form-col-1">tissue:</label>
+ <select id="tissue" name="tissueid" class="form-col-2">
+ </select>
+ </fieldset>
+
+ <fieldset>
+ <input type="submit" value="create study"
+ class="btn btn-main form-col-2" />
+ </fieldset>
+ </form>
+</div>
+
+{%endblock%}