From 270aa749638ab917920a77ec9e8d41eb24c80e1a Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 25 Mar 2022 20:57:32 +0000 Subject: Fix issues that prevented genotype traits from being added to collections Some of this was caused by heatmaps supporting code; that code should probably pass the traits differently than the way it does in the "trait_info_str" function --- wqflask/base/trait.py | 1 + wqflask/wqflask/collect.py | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index f0749858..ee5dda38 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -94,6 +94,7 @@ class GeneralTrait: self.num_overlap = None self.strand_probe = None self.symbol = None + self.abbreviation = None self.display_name = self.name self.LRS_score_repr = "N/A" diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 815bb7c1..de61323a 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -200,18 +200,33 @@ def trait_info_str(trait): return (trt.symbol or trt.abbreviation or "N/A")[:20] def __lrs(trt): - return ( - f"{float(trait.LRS_score_repr):0.3f}" if float(trait.LRS_score_repr) > 0 - else f"{trait.LRS_score_repr}") + if trait.dataset.type == "Geno": + return 0 + else: + return ( + f"{float(trait.LRS_score_repr):0.3f}" if float(trait.LRS_score_repr) > 0 + else f"{trait.LRS_score_repr}") + + def __lrs_location(trt): + if hasattr(trt, "LRS_location_repr"): + return trt.LRS_location_repr + else: + return "N/A" def __location(trt): if hasattr(trt, "location_repr"): return trt.location_repr return None + def __mean(trt): + if trait.mean: + return trt.mean + else: + return 0 + return "{}|||{}|||{}|||{}|||{}|||{:0.3f}|||{}|||{}".format( trait.name, trait.dataset.name, __trait_desc(trait), __symbol(trait), - __location(trait), trait.mean, __lrs(trait), trait.LRS_location_repr) + __location(trait), __mean(trait), __lrs(trait), __lrs_location(trait)) @app.route("/collections/view") def view_collection(): -- cgit v1.2.3