diff options
Diffstat (limited to 'uploader')
-rw-r--r-- | uploader/genotypes/models.py | 16 | ||||
-rw-r--r-- | uploader/genotypes/views.py | 13 | ||||
-rw-r--r-- | uploader/templates/genotypes/list-genotypes.html | 20 |
3 files changed, 49 insertions, 0 deletions
diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 53c5fb8..642caa6 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -39,3 +39,19 @@ def genotype_markers( cursor.execute(_query, (species_id,)) debug_query(cursor) return tuple(dict(row) for row in cursor.fetchall()) + + +def genotype_datasets( + conn: mdb.Connection, + species_id: int, + population_id: int +) -> tuple[dict, ...]: + """Retrieve genotype datasets from the database.""" + 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)) + return tuple(dict(row) for row in cursor.fetchall()) diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 2ff9965..294da0e 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -15,6 +15,7 @@ from uploader.population.models import (populations_by_species, population_by_species_and_id) from .models import (genotype_markers, + genotype_datasets, genotype_markers_count, genocode_by_population) @@ -97,6 +98,8 @@ def list_genotypes(species_id: int, population_id: int): conn, population_id), total_markers=genotype_markers_count( conn, species_id), + datasets=genotype_datasets( + conn, species_id, population_id), activelink="list-genotypes") @@ -125,3 +128,13 @@ def list_markers(species_id: int): count=count, markers=markers, activelink="list-markers") + +@genotypesbp.route( + "/<int:species_id>/populations/<int:population_id>/genotypes/datasets/" + "<int:dataset_id>/view", + methods=["GET"]) +@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}'.") diff --git a/uploader/templates/genotypes/list-genotypes.html b/uploader/templates/genotypes/list-genotypes.html index 31b9eeb..8afd591 100644 --- a/uploader/templates/genotypes/list-genotypes.html +++ b/uploader/templates/genotypes/list-genotypes.html @@ -104,6 +104,26 @@ {%if datasets | length > 0%} <table class="table"> + <thead> + <tr> + <th>Name</th> + <th>Full Name</th> + </tr> + </thead> + + <tbody> + {%for dataset in datasets%} + <tr> + <td>{{dataset.Name}}</td> + <td><a href="{{url_for('species.populations.genotypes.view_dataset', + species_id=species.SpeciesId, + population_id=population.Id, + dataset_id=dataset.Id)}}" + title="View details regarding and manage dataset '{{dataset.FullName}}'"> + {{dataset.FullName}}</a></td> + </tr> + {%endfor%} + </tbody> </table> {%else%} <p class="text-warning"> |