From 64880f86cdf67c963470098c2aa17d1598fe60e0 Mon Sep 17 00:00:00 2001 From: francastell Date: Thu, 7 Nov 2024 15:21:26 -0500 Subject: [PATCH 1/3] G3-495 adding threshold value to the geneset detail view GW legacy --- pyproject.toml | 2 +- src/application.py | 58 ++++++++++++++++++++++++++++++++++ src/templates/genesetMeta.html | 11 +++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bf9abf73..1835fc5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-legacy" -version = "1.4.7" +version = "1.4.8" description = "" authors = ["Alexander Berger "] readme = "README.md" diff --git a/src/application.py b/src/application.py index 16f5a80e..c83992b8 100644 --- a/src/application.py +++ b/src/application.py @@ -38,6 +38,7 @@ from authlib.integrations.base_client.errors import OAuthError from decorators import login_required, create_guest, restrict_to_current_user +from src.error import internal_server_error from tools import abbablueprint from tools import booleanalgebrablueprint from tools import combineblueprint @@ -2745,6 +2746,9 @@ def render_viewgeneset_main(gs_id, curation_view=None, curation_team=None, curat for sp_id, sp_name in geneweaverdb.get_all_species().items(): species.append([sp_id, sp_name]) + # Try to get formated threshold value from geneset threshold + threshold_value = format_str_threshold_value(geneset) + return render_template( 'viewgenesetdetails.html', gs_id=gs_id, @@ -2765,11 +2769,65 @@ def render_viewgeneset_main(gs_id, curation_view=None, curation_team=None, curat show_gene_list=show_gene_list, totalGenes=numgenes, uploaded_as=uploaded_as, + threshold_value=threshold_value, #SRP IMPLEMENTATION srp=srp #SRP IMPLEMENTATION END ) +def format_str_threshold_value(geneset: dict) -> str: + """ + Formats the threshold value for a gene set to be displayed in the gene set + details page, + - if the threshold is set and the values are numbers a formatted string value is returned, otherwise None is returned. + - if the threshold is a single value, it is formatted as "< value" + - if the threshold is a range, it is formatted as "value1 < value2" + - if the threshold is binary type(3), None is returned + - if the threshold values are the same, None is returned + + arguments + geneset: a GeneSet object + + returns + a string representation of the threshold value + """ + print (geneset) + response = None + type = geneset.threshold_type + + ## if binary type return None + if type == 3: + return None + + threshold = str(geneset.threshold) + + if threshold is not None: + thresh = threshold.split(',') + if len(thresh) == 1: + if not is_number(thresh[0]): + response= None + else: + response= "< " + thresh[0] + + elif len(thresh) > 1: + if not is_number(thresh[0]) or not is_number(thresh[1]): + response= None + elif thresh[0] == thresh[1]: + response= None + else: + response= thresh[0] + " < " + thresh[1] + + return response + +def is_number(input): + """ Checks if the input is a number""" + try: + float(input) + return True + except ValueError: + return False + + @app.route('/viewgenesetoverlap/', methods=['GET']) @login_required(allow_guests=True) def render_viewgenesetoverlap(gs_ids): diff --git a/src/templates/genesetMeta.html b/src/templates/genesetMeta.html index 9f17719b..f4697efa 100644 --- a/src/templates/genesetMeta.html +++ b/src/templates/genesetMeta.html @@ -34,6 +34,17 @@ + {% if threshold_value%} +
+
+

THRESHOLD:

+
+
+

{{ threshold_value }}

+
+
+ {% endif %} +

DATE ADDED:

From cc4d5a44dcfd8426541f74500d86abff958c96f5 Mon Sep 17 00:00:00 2001 From: francastell Date: Thu, 7 Nov 2024 15:34:35 -0500 Subject: [PATCH 2/3] G3-495 version udpate --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1835fc5f..8612b405 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-legacy" -version = "1.4.8" +version = "1.5.1" description = "" authors = ["Alexander Berger "] readme = "README.md" From 1201d21d1ded4000f465a446a69f808420d61acc Mon Sep 17 00:00:00 2001 From: francastell Date: Mon, 11 Nov 2024 09:50:17 -0500 Subject: [PATCH 3/3] G3-495 version udpate, clean up --- pyproject.toml | 2 +- src/application.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8612b405..f28c6e09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-legacy" -version = "1.5.1" +version = "1.5.2" description = "" authors = ["Alexander Berger "] readme = "README.md" diff --git a/src/application.py b/src/application.py index c83992b8..b73aa1f4 100644 --- a/src/application.py +++ b/src/application.py @@ -2791,7 +2791,6 @@ def format_str_threshold_value(geneset: dict) -> str: returns a string representation of the threshold value """ - print (geneset) response = None type = geneset.threshold_type