aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-26 14:18:45 -0500
committerFrederick Muriuki Muriithi2024-09-26 14:18:45 -0500
commitd13071900de2ba73b829f52b96a1593da600118a (patch)
tree656b674a3b34bbb6650ca6a07b54f8e23660c697
parentc542cecda4c7c21bde7668f19a1b3e20f9a2b7b9 (diff)
downloadgn-uploader-d13071900de2ba73b829f52b96a1593da600118a.tar.gz
Initialise the phenotypes section.
-rw-r--r--uploader/phenotypes/__init__.py2
-rw-r--r--uploader/phenotypes/views.py25
-rw-r--r--uploader/population/views.py2
-rw-r--r--uploader/templates/base.html3
-rw-r--r--uploader/templates/phenotypes/base.html12
-rw-r--r--uploader/templates/phenotypes/index.html26
6 files changed, 68 insertions, 2 deletions
diff --git a/uploader/phenotypes/__init__.py b/uploader/phenotypes/__init__.py
new file mode 100644
index 0000000..c17d32c
--- /dev/null
+++ b/uploader/phenotypes/__init__.py
@@ -0,0 +1,2 @@
+"""Package for handling ('classical') phenotype data"""
+from .views import phenotypesbp
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
new file mode 100644
index 0000000..862a224
--- /dev/null
+++ b/uploader/phenotypes/views.py
@@ -0,0 +1,25 @@
+"""Views handling ('classical') phenotypes."""
+from flask import request, Blueprint, render_template, current_app as app
+
+from uploader.datautils import order_by_family
+from uploader.authorisation import require_login
+from uploader.db_utils import database_connection
+from uploader.species.models import all_species, species_by_id
+
+phenotypesbp = Blueprint("phenotypes", __name__)
+
+@phenotypesbp.route("/phenotypes", methods=["GET"])
+@require_login
+def index():
+ """Direct entry-point for phenotypes data handling."""
+ with database_connection(app.config["SQL_URI"]) as conn:
+ if not bool(request.args.get("species_id")):
+ return render_template("phenotypes/index.html",
+ species=order_by_family(all_species(conn)),
+ activelink="phenotypes")
+
+ species = species_by_id(conn, request.args.get("species_id"))
+ if not bool(species):
+ flash("No such species!", "alert-danger")
+ return redirect(url_for("species.populations.phenotypes.index"))
+ return "Would lead you to go select population…"
diff --git a/uploader/population/views.py b/uploader/population/views.py
index 631f0be..23bf242 100644
--- a/uploader/population/views.py
+++ b/uploader/population/views.py
@@ -18,6 +18,7 @@ from uploader.oauth2.client import oauth2_post
from uploader.ui import make_template_renderer
from uploader.authorisation import require_login
from uploader.genotypes.views import genotypesbp
+from uploader.phenotypes.views import phenotypesbp
from uploader.expression_data.views import exprdatabp
from uploader.db_utils import database_connection
from uploader.datautils import enumerate_sequence
@@ -35,6 +36,7 @@ __active_link__ = "populations"
popbp = Blueprint("populations", __name__)
popbp.register_blueprint(samplesbp, url_prefix="/")
popbp.register_blueprint(genotypesbp, url_prefix="/")
+popbp.register_blueprint(phenotypesbp, url_prefix="/")
popbp.register_blueprint(exprdatabp, url_prefix="/")
render_template = make_template_renderer("populations")
diff --git a/uploader/templates/base.html b/uploader/templates/base.html
index b297669..019aa39 100644
--- a/uploader/templates/base.html
+++ b/uploader/templates/base.html
@@ -68,8 +68,7 @@
sections, etc.
-->
<li {%if activemenu=="phenotypes"%}class="activemenu"{%endif%}>
- <a href="#"
- class="not-implemented"
+ <a href="{{url_for('species.populations.phenotypes.index')}}"
title="Upload phenotype data.">Phenotype Data</a></li>
<li {%if activemenu=="expression-data"%}class="activemenu"{%endif%}>
<a href="{{url_for('species.populations.expression-data.index')}}"
diff --git a/uploader/templates/phenotypes/base.html b/uploader/templates/phenotypes/base.html
new file mode 100644
index 0000000..3bc5dea
--- /dev/null
+++ b/uploader/templates/phenotypes/base.html
@@ -0,0 +1,12 @@
+{%extends "populations/base.html"%}
+
+{%block lvl3_breadcrumbs%}
+<li {%if activelink=="phenotypes"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.populations.phenotypes.index')}}">Phenotypes</a>
+</li>
+{%block lvl4_breadcrumbs%}{%endblock%}
+{%endblock%}
diff --git a/uploader/templates/phenotypes/index.html b/uploader/templates/phenotypes/index.html
new file mode 100644
index 0000000..0c691e6
--- /dev/null
+++ b/uploader/templates/phenotypes/index.html
@@ -0,0 +1,26 @@
+{%extends "phenotypes/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "species/macro-select-species.html" import select_species_form%}
+
+{%block title%}Phenotypes{%endblock%}
+
+{%block pagetitle%}Phenotypes{%endblock%}
+
+
+{%block contents%}
+{{flash_all_messages()}}
+
+<div class="row">
+ <p>This section deals with phenotypes that
+ <span class="text-warning">
+ <span class="glyphicon glyphicon-exclamation-sign"></span>
+ … what are the characteristics of these phenotypes? …</span></p>
+ <p>Select the species to begin the process of viewing/uploading data about
+ your phenotypes</p>
+</div>
+
+<div class="row">
+ {{select_species_form(url_for("species.populations.phenotypes.index"),
+ species)}}
+</div>
+{%endblock%}