From d13071900de2ba73b829f52b96a1593da600118a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 26 Sep 2024 14:18:45 -0500 Subject: Initialise the phenotypes section. --- uploader/phenotypes/__init__.py | 2 ++ uploader/phenotypes/views.py | 25 +++++++++++++++++++++++++ uploader/population/views.py | 2 ++ uploader/templates/base.html | 3 +-- uploader/templates/phenotypes/base.html | 12 ++++++++++++ uploader/templates/phenotypes/index.html | 26 ++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 uploader/phenotypes/__init__.py create mode 100644 uploader/phenotypes/views.py create mode 100644 uploader/templates/phenotypes/base.html create mode 100644 uploader/templates/phenotypes/index.html 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. -->
This section deals with phenotypes that + + + … what are the characteristics of these phenotypes? …
+Select the species to begin the process of viewing/uploading data about + your phenotypes
+