Skip to content

Commit

Permalink
Merge pull request #27 from TheJacksonLaboratory/G3-495-UI-threshold-…
Browse files Browse the repository at this point in the history
…geneset-details-view

G3 495 UI threshold geneset details view
  • Loading branch information
francastell authored Nov 11, 2024
2 parents 01b446e + 054f156 commit 3425358
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "geneweaver-legacy"
version = "1.5.1"
version = "1.5.2"
description = ""
authors = ["Alexander Berger <alexander.berger@jax.org>"]
readme = "README.md"
Expand Down
57 changes: 57 additions & 0 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2800,6 +2801,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,
Expand All @@ -2820,11 +2824,64 @@ 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
"""
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/<list:gs_ids>', methods=['GET'])
@login_required(allow_guests=True)
def render_viewgenesetoverlap(gs_ids):
Expand Down
11 changes: 11 additions & 0 deletions src/templates/genesetMeta.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
</div>
</div>

{% if threshold_value%}
<div class="row">
<div class="col-md-2">
<p class="text-right"><strong>THRESHOLD:</strong></p>
</div>
<div class="col-md-10">
<p>{{ threshold_value }}</p>
</div>
</div>
{% endif %}

<div class="row">
<div class="col-md-2">
<p class="text-right"><strong>DATE ADDED:</strong></p>
Expand Down

0 comments on commit 3425358

Please sign in to comment.