aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-18 17:10:50 -0500
committerFrederick Muriuki Muriithi2024-09-18 17:11:53 -0500
commit66e7970c3ff5305f8a7d6d60d34b974389f8fe78 (patch)
tree6e6d5fd819dee82b88439c828e4083000ef6e1cf
parent590ef1232032958dd448c2eaa9ca760e008a9687 (diff)
downloadgn-uploader-66e7970c3ff5305f8a7d6d60d34b974389f8fe78.tar.gz
Separate genetic markers from encodings and datasets
-rw-r--r--uploader/genotypes/views.py27
-rw-r--r--uploader/templates/genotypes/list-genotypes.html87
-rw-r--r--uploader/templates/genotypes/list-markers.html102
3 files changed, 146 insertions, 70 deletions
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("/<int:species_id>/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()}}
<div class="row">
+ <h2>Genetic Markers</h2>
+ <p>There are a total of {{total_markers}} currently registered genetic markers
+ for the "{{species.FullName}}" species. You can click
+ <a href="{{url_for('species.populations.genotypes.list_markers',
+ species_id=species.SpeciesId)}}"
+ title="View genetic markers for species '{{species.FullName}}">
+ this link to view the genetic markers
+ </a>.
+ </p>
+</div>
+
+<div class="row">
+ <h2>Genotype Encoding</h2>
<p>
The genotype encoding used for the "{{population.FullName}}" population from
the "{{species.FullName}}" species is as shown in the table below.
</p>
<table class="table">
- <legend>Genotype Encoding</legend>
<thead>
<tr>
@@ -54,6 +66,14 @@
{%endfor%}
</tbody>
</table>
+
+ {%if genocode | length < 1%}
+ <a href="#add-genotype-encoding"
+ title="Add a genotype encoding system for this population"
+ class="btn btn-primary">
+ add genotype encoding
+ </a>
+ {%endif%}
</div>
<div class="row text-danger">
@@ -65,75 +85,12 @@
<h3>Possible references</h3>
<ul>
<li>https://mr-dictionary.mrcieu.ac.uk/term/genotype/</li>
+ <li>https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7363099/</li>
</ul>
</div>
<div class="row">
- <p>
- There are a total of {{total_markers}} genotype markers for this species.
- </p>
- <div class="row">
- <div class="col-md-2" style="text-align: start;">
- {%if start_from > 0%}
- <a href="{{url_for('species.populations.genotypes.list_genotypes',
- species_id=species.SpeciesId,
- population_id=population.Id,
- start_from=start_from-count,
- count=count)}}">
- <span class="glyphicon glyphicon-backward"></span>
- Previous
- </a>
- {%endif%}
- </div>
- <div class="col-md-8" style="text-align: center;">
- Displaying markers {{start_from+1}} to {{start_from + count}} of
- {{total_markers}}
- </div>
- <div class="col-md-2" style="text-align: end;">
- {%if start_from + count < total_markers%}
- <a href="{{url_for('species.populations.genotypes.list_genotypes',
- species_id=species.SpeciesId,
- population_id=population.Id,
- start_from=start_from+count,
- count=count)}}">
- Next
- <span class="glyphicon glyphicon-forward"></span>
- </a>
- {%endif%}
- </div>
- </div>
- <table class="table">
- <thead>
- <tr>
- <th title="">#</th>
- <th title="">Marker Name</th>
- <th title="Chromosome">Chr</th>
- <th title="Physical location of the marker in megabasepairs">
- Location (Mb)</th>
- <th title="">Source</th>
- <th title="">Source2</th>
- </thead>
- <tbody>
- {%for marker in markers%}
- <tr>
- <td>{{marker.sequence_number}}</td>
- <td>{{marker.Marker_Name}}</td>
- <td>{{marker.Chr}}</td>
- <td>{{marker.Mb}}</td>
- <td>{{marker.Source}}</td>
- <td>{{marker.Source2}}</td>
- </tr>
- {%else%}
- <tr>
- <td colspan="7" class="text-info">
- <span class="glyphicon glyphicon-exclamation-sign"></span>
- No markers to display!
- </td>
- </tr>
- {%endfor%}
- </tbody>
- </table>
</div>
{%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%}
+<li {%if activelink=="list-markers"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.populations.genotypes.list_markers',
+ species_id=species.SpeciesId)}}">List markers</a>
+</li>
+{%endblock%}
+
+{%block contents%}
+{{flash_all_messages()}}
+
+{%if markers | length > 0%}
+<div class="row">
+ <p>
+ There are a total of {{total_markers}} genotype markers for this species.
+ </p>
+ <div class="row">
+ <div class="col-md-2" style="text-align: start;">
+ {%if start_from > 0%}
+ <a href="{{url_for('species.populations.genotypes.list_markers',
+ species_id=species.SpeciesId,
+ start_from=start_from-count,
+ count=count)}}">
+ <span class="glyphicon glyphicon-backward"></span>
+ Previous
+ </a>
+ {%endif%}
+ </div>
+ <div class="col-md-8" style="text-align: center;">
+ Displaying markers {{start_from+1}} to {{start_from+count if start_from+count < total_markers else total_markers}} of
+ {{total_markers}}
+ </div>
+ <div class="col-md-2" style="text-align: end;">
+ {%if start_from + count < total_markers%}
+ <a href="{{url_for('species.populations.genotypes.list_markers',
+ species_id=species.SpeciesId,
+ start_from=start_from+count,
+ count=count)}}">
+ Next
+ <span class="glyphicon glyphicon-forward"></span>
+ </a>
+ {%endif%}
+ </div>
+ </div>
+ <table class="table">
+ <thead>
+ <tr>
+ <th title="">#</th>
+ <th title="">Marker Name</th>
+ <th title="Chromosome">Chr</th>
+ <th title="Physical location of the marker in megabasepairs">
+ Location (Mb)</th>
+ <th title="">Source</th>
+ <th title="">Source2</th>
+ </thead>
+
+ <tbody>
+ {%for marker in markers%}
+ <tr>
+ <td>{{marker.sequence_number}}</td>
+ <td>{{marker.Marker_Name}}</td>
+ <td>{{marker.Chr}}</td>
+ <td>{{marker.Mb}}</td>
+ <td>{{marker.Source}}</td>
+ <td>{{marker.Source2}}</td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+</div>
+{%else%}
+<div class="row">
+ <p class="text-warning">
+ <span class="glyphicon glyphicon-exclamation-sign"></span>
+ This species does not currently have any genetic markers uploaded, therefore,
+ there is nothing to display here.
+ </p>
+ <p>
+ <a href="#add-genetic-markers-for-species-{{species.SpeciesId}}"
+ title="Add genetic markers for this species"
+ class="btn btn-primary">
+ add genetic markers
+ </a>
+ </p>
+</div>
+{%endif%}
+{%endblock%}
+
+{%block sidebarcontents%}
+{{display_species_card(species)}}
+{%endblock%}