From 66e7970c3ff5305f8a7d6d60d34b974389f8fe78 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 18 Sep 2024 17:10:50 -0500 Subject: Separate genetic markers from encodings and datasets --- uploader/genotypes/views.py | 27 ++++-- uploader/templates/genotypes/list-genotypes.html | 87 +++++-------------- uploader/templates/genotypes/list-markers.html | 102 +++++++++++++++++++++++ 3 files changed, 146 insertions(+), 70 deletions(-) create mode 100644 uploader/templates/genotypes/list-markers.html diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 0618949..2ff9965 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -90,6 +90,26 @@ def list_genotypes(species_id: int, population_id: int): "species.populations.genotypes.select_population", species_id=species_id)) + return render_template("genotypes/list-genotypes.html", + species=species, + population=population, + genocode=genocode_by_population( + conn, population_id), + total_markers=genotype_markers_count( + conn, species_id), + activelink="list-genotypes") + + +@genotypesbp.route("//genotypes/list-markers", methods=["GET"]) +@require_login +def list_markers(species_id: int): + """List a species' genetic markers.""" + 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")) + start_from = safe_int(request.args.get("start_from") or 0) if start_from < 0: start_from = 0 @@ -97,14 +117,11 @@ def list_genotypes(species_id: int, population_id: int): markers = enumerate_sequence( genotype_markers(conn, species_id, offset=start_from, limit=count), start=start_from+1) - return render_template("genotypes/list-genotypes.html", + return render_template("genotypes/list-markers.html", species=species, - population=population, - genocode=genocode_by_population( - conn, population_id), total_markers=genotype_markers_count( conn, species_id), start_from=start_from, count=count, markers=markers, - activelink="list-genotypes") + activelink="list-markers") diff --git a/uploader/templates/genotypes/list-genotypes.html b/uploader/templates/genotypes/list-genotypes.html index 9b27540..0efc693 100644 --- a/uploader/templates/genotypes/list-genotypes.html +++ b/uploader/templates/genotypes/list-genotypes.html @@ -22,12 +22,24 @@ {{flash_all_messages()}}
+

Genetic Markers

+

There are a total of {{total_markers}} currently registered genetic markers + for the "{{species.FullName}}" species. You can click + + this link to view the genetic markers + . +

+
+ +
+

Genotype Encoding

The genotype encoding used for the "{{population.FullName}}" population from the "{{species.FullName}}" species is as shown in the table below.

- Genotype Encoding @@ -54,6 +66,14 @@ {%endfor%}
+ + {%if genocode | length < 1%} + + add genotype encoding + + {%endif%}
@@ -65,75 +85,12 @@

Possible references

-

- There are a total of {{total_markers}} genotype markers for this species. -

-
-
- {%if start_from > 0%} - - - Previous - - {%endif%} -
-
- Displaying markers {{start_from+1}} to {{start_from + count}} of - {{total_markers}} -
-
- {%if start_from + count < total_markers%} - - Next - - - {%endif%} -
-
- - - - - - - - - - - - {%for marker in markers%} - - - - - - - - - {%else%} - - - - {%endfor%} - -
#Marker NameChr - Location (Mb)SourceSource2
{{marker.sequence_number}}{{marker.Marker_Name}}{{marker.Chr}}{{marker.Mb}}{{marker.Source}}{{marker.Source2}}
- - No markers to display! -
{%endblock%} diff --git a/uploader/templates/genotypes/list-markers.html b/uploader/templates/genotypes/list-markers.html new file mode 100644 index 0000000..9198b44 --- /dev/null +++ b/uploader/templates/genotypes/list-markers.html @@ -0,0 +1,102 @@ +{%extends "genotypes/base.html"%} +{%from "flash_messages.html" import flash_all_messages%} +{%from "species/macro-display-species-card.html" import display_species_card%} + +{%block title%}Genotypes: List Markers{%endblock%} + +{%block pagetitle%}Genotypes: List Markers{%endblock%} + +{%block lvl4_breadcrumbs%} + +{%endblock%} + +{%block contents%} +{{flash_all_messages()}} + +{%if markers | length > 0%} +
+

+ There are a total of {{total_markers}} genotype markers for this species. +

+
+
+ {%if start_from > 0%} + + + Previous + + {%endif%} +
+
+ Displaying markers {{start_from+1}} to {{start_from+count if start_from+count < total_markers else total_markers}} of + {{total_markers}} +
+
+ {%if start_from + count < total_markers%} + + Next + + + {%endif%} +
+
+ + + + + + + + + + + + + {%for marker in markers%} + + + + + + + + + {%endfor%} + +
#Marker NameChr + Location (Mb)SourceSource2
{{marker.sequence_number}}{{marker.Marker_Name}}{{marker.Chr}}{{marker.Mb}}{{marker.Source}}{{marker.Source2}}
+
+{%else%} +
+

+ + This species does not currently have any genetic markers uploaded, therefore, + there is nothing to display here. +

+

+ + add genetic markers + +

+
+{%endif%} +{%endblock%} + +{%block sidebarcontents%} +{{display_species_card(species)}} +{%endblock%} -- cgit v1.2.3