diff options
author | Frederick Muriuki Muriithi | 2024-09-20 16:10:50 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-09-20 16:10:50 -0500 |
commit | 27eec3300eddbc17214b3ff3ffbd8bea867db401 (patch) | |
tree | df15cc72916a9055b192205cb63c3cfaf1bb424f | |
parent | d4fd4693423d99f500bfcd65cea42ed47e8d59e0 (diff) | |
download | gn-uploader-27eec3300eddbc17214b3ff3ffbd8bea867db401.tar.gz |
Initialise UI for managing genotype datasets.
-rw-r--r-- | uploader/genotypes/models.py | 21 | ||||
-rw-r--r-- | uploader/genotypes/views.py | 29 | ||||
-rw-r--r-- | uploader/templates/genotypes/list-genotypes.html | 10 | ||||
-rw-r--r-- | uploader/templates/genotypes/view-dataset.html | 61 |
4 files changed, 112 insertions, 9 deletions
diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 29acd0b..1fe5929 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -44,19 +44,26 @@ def genotype_markers( def genotype_dataset( conn: mdb.Connection, species_id: int, - population_id: int + population_id: int, + dataset_id: Optional[int] = None ) -> Optional[dict]: """Retrieve genotype datasets from the database. Apparently, you should only ever have one genotype dataset for a population. """ + _query = ( + "SELECT gf.* FROM Species AS s INNER JOIN InbredSet AS iset " + "ON s.Id=iset.SpeciesId INNER JOIN GenoFreeze AS gf " + "ON iset.Id=gf.InbredSetId " + "WHERE s.Id=%s AND iset.Id=%s") + _params = (species_id, population_id) + if bool(dataset_id): + _query = _query + " AND gf.Id=%s" + _params = _params + (dataset_id,) + with conn.cursor(cursorclass=DictCursor) as cursor: - cursor.execute( - "SELECT gf.* FROM Species AS s INNER JOIN InbredSet AS iset " - "ON s.Id=iset.SpeciesId INNER JOIN GenoFreeze AS gf " - "ON iset.Id=gf.InbredSetId " - "WHERE s.Id=%s AND iset.Id=%s", - (species_id, population_id)) + cursor.execute(_query, _params) + debug_query(cursor) result = cursor.fetchone() if bool(result): return dict(result) diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 8752b02..4158491 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -136,5 +136,30 @@ def list_markers(species_id: int): @require_login def view_dataset(species_id: int, population_id: int, dataset_id: int): """View details regarding a specific dataset.""" - return (f"Genotype dataset '{dataset_id}, from population '{population_id}' " - f"of species '{species_id}'.") + with database_connection(app.config["SQL_URI"]) as conn: + species = species_by_id(conn, species_id) + if not bool(species): + flash("Invalid species provided!", "alert-danger") + return redirect(url_for("species.populations.genotypes.index")) + + population = population_by_species_and_id( + conn, species_id, population_id) + if not bool(population): + flash("Invalid population selected!", "alert-danger") + return redirect(url_for( + "species.populations.genotypes.select_population", + species_id=species_id)) + + dataset = genotype_dataset(conn, species_id, population_id, dataset_id) + if not bool(dataset): + flash("Could not find such a dataset!", "alert-danger") + return redirect(url_for( + "species.populations.genotypes.list_genotypes", + species_id=species_id, + population_id=population_id)) + + return render_template("genotypes/view-dataset.html", + species=species, + population=population, + dataset=dataset, + activelink="view-dataset") diff --git a/uploader/templates/genotypes/list-genotypes.html b/uploader/templates/genotypes/list-genotypes.html index 3780f85..864e1ec 100644 --- a/uploader/templates/genotypes/list-genotypes.html +++ b/uploader/templates/genotypes/list-genotypes.html @@ -129,6 +129,16 @@ create new genotype dataset</a></p> {%endif%} </div> +<div class="row text-warning"> + <p> + <span class="glyphicon glyphicon-exclamation-sign"></span> + <strong>NOTE</strong>: Currently the GN2 (and related) system(s) expect a + single genotype dataset. If there is more than one, the system apparently + fails in unpredictable ways. + </p> + <p>Fix this to allow multiple datasets, each with a different assembly from + all the rest.</p> +</div> {%endblock%} {%block sidebarcontents%} diff --git a/uploader/templates/genotypes/view-dataset.html b/uploader/templates/genotypes/view-dataset.html new file mode 100644 index 0000000..e7ceb36 --- /dev/null +++ b/uploader/templates/genotypes/view-dataset.html @@ -0,0 +1,61 @@ +{%extends "genotypes/base.html"%} +{%from "flash_messages.html" import flash_all_messages%} +{%from "populations/macro-display-population-card.html" import display_population_card%} + +{%block title%}Genotypes: View Dataset{%endblock%} + +{%block pagetitle%}Genotypes: View Dataset{%endblock%} + +{%block lvl4_breadcrumbs%} +<li {%if activelink=="view-dataset"%} + class="breadcrumb-item active" + {%else%} + class="breadcrumb-item" + {%endif%}> + <a href="{{url_for('species.populations.genotypes.view_dataset', + species_id=species.SpeciesId, + population_id=population.Id, + dataset_id=dataset.Id)}}">view dataset</a> +</li> +{%endblock%} + +{%block contents%} +{{flash_all_messages()}} + +<div class="row"> + <h2>Genotype Dataset Details</h2> + <table class="table"> + <thead> + <tr> + <th>Name</th> + <th>Full Name</th> + </tr> + </thead> + + <tbody> + <tr> + <td>{{dataset.Name}}</td> + <td>{{dataset.FullName}}</td> + </tr> + </tbody> + </table> +</div> + +<div class="row text-warning"> + <h2>Assembly Details</h2> + + <p>Maybe include the assembly details here if found to be necessary.</p> +</div> + +<div class="row"> + <h2>Genotype Data</h2> + + <p class="text-danger"> + Provide link to enable uploading of genotype data here.</p> +</div> + +{%endblock%} + +{%block sidebarcontents%} +{{display_population_card(species, population)}} +{%endblock%} |