diff options
| author | Frederick Muriuki Muriithi | 2026-04-13 13:47:57 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-13 13:55:11 -0500 |
| commit | 2b83212a830cbaef8575be3b0996a7d838c16c01 (patch) | |
| tree | 0b2248259522276d7a0a7e45ea1f69ff8a6332ac | |
| parent | 2981951d059afc4e21b59bc6ec9f3983b5213547 (diff) | |
| download | gn-uploader-2b83212a830cbaef8575be3b0996a7d838c16c01.tar.gz | |
Retrieve ALL markers for a species regardless of data.
Retrieve all the genetic markers that exist for a particular species regardless of whether or not a particular marker has corresponding samples allele data.
| -rw-r--r-- | uploader/genotypes/models.py | 13 | ||||
| -rw-r--r-- | uploader/genotypes/views.py | 12 | ||||
| -rw-r--r-- | uploader/templates/genotypes/list-genotypes.html | 26 |
3 files changed, 24 insertions, 27 deletions
diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 4f09b02..34d2cfe 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -29,29 +29,28 @@ def genotype_markers_count(conn: mdb.Connection, species_id: int) -> int: def genotype_markers( conn: mdb.Connection, species_id: int, - dataset_id: int, offset: int = 0, limit: Optional[int] = None ) -> tuple[tuple[dict, ...], int]: """Retrieve markers from the database.""" _query_template = ( - "SELECT %%COLS%% FROM GenoXRef AS gxr INNER JOIN Geno AS gno " - "ON gxr.GenoId=gno.Id WHERE gxr.GenoFreezeId=%s AND gno.SpeciesId=%s " + "SELECT %%COLS%% FROM Geno AS gno " + "WHERE gno.SpeciesId=%s " "%%LIMIT%%") with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( _query_template.replace("%%LIMIT%%", "").replace( - "%%COLS%%", "COUNT(gxr.GenoId) AS total_records"), - (species_id, dataset_id)) + "%%COLS%%", "COUNT(gno.Id) AS total_records"), + (species_id,)) _total_records = cursor.fetchone()["total_records"] cursor.execute( - _query_template.replace("%%COLS%%", "gxr.GenoFreezeId, gno.*").replace( + _query_template.replace("%%COLS%%", "gno.*").replace( "%%LIMIT%%", (f"LIMIT {int(limit)} OFFSET {int(offset)}" if bool(limit) and limit > 0 else "")), - (species_id, dataset_id)) + (species_id,)) debug_query(cursor, app.logger) return tuple(dict(row) for row in cursor.fetchall()), _total_records diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 42f41a8..f27671c 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -60,17 +60,15 @@ def list_genotypes(species: dict, population: dict, **kwargs):# pylint: disable= "/<int:species_id>/populations/<int:population_id>/genotypes/<int:dataset_id>/list-markers", methods=["GET"]) @require_login -@with_dataset(species_redirect_uri="species.list_species", - population_redirect_uri="species.populations.list_species_populations", - redirect_uri="species.populations.genotypes.list_genotypes", - dataset_by_id=genotype_dataset) -def list_markers(species: dict, population: dict, dataset: dict, **_kwargs): - """List the markers uploaded for this dataset.""" +@with_species(redirect_uri="species.populations.genotypes.list_genotypes") +def list_markers(species: dict, **_kwargs): + """List the markers that exist for this species.""" args = request.args offset = int(args.get("start") or 0) with database_connection(app.config["SQL_URI"]) as conn: markers, total_records = genotype_markers( - conn, species["SpeciesId"], dataset["Id"], + conn, + species["SpeciesId"], offset=offset, limit=int(args.get("length") or 0)) return jsonify({ diff --git a/uploader/templates/genotypes/list-genotypes.html b/uploader/templates/genotypes/list-genotypes.html index 38a1b8f..131576f 100644 --- a/uploader/templates/genotypes/list-genotypes.html +++ b/uploader/templates/genotypes/list-genotypes.html @@ -60,6 +60,7 @@ {%if dataset is not none%} <div class="row"> + <h3>Dataset Details</h3> <table class="table"> <thead> <tr> @@ -81,17 +82,22 @@ </tr> </tbody> </table> -</div> - -<div class="row"> - <h3>Genotype Data</h3> - <div class="col" style="margin-bottom: 3px;"> - <a href="#" class="btn btn-primary">upload genotypes</a> - </div> + <p> + To see more information regarding this dataset (e.g. which markers have + sample allele data, the allele data itself, etc) click on the "Full Name" + link above.</p> </div> <div class="row"> + <h3>Genotype Markers</h3> + + <div class="row"> + <p> + The table below lists all of the markers that exist for species + {{species.SpeciesName}} ({{species.FullName}}), regardless of whether + (or not) we have corresponding sample allele data for a particular marker. + </p> <table id="tbl-genetic-markers" class="table compact stripe cell-border"> <thead> <tr> @@ -121,12 +127,6 @@ </table> </div> -<div class="row text-warning"> - <h3>Assembly Details</h3> - - <p>Maybe include the assembly details here if found to be necessary.</p> -</div> - {%else%} <div class="row"> |
