From b94fa5dea9f4228341f0e664b2641fe9e6f0f450 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 26 Apr 2019 13:54:07 -0500
Subject: Fixed issue where changed smaple values didn't show up in haplotype
analyst results
---
wqflask/wqflask/correlation/show_corr_results.py | 81 ++++++++++++----------
.../marker_regression/display_mapping_results.py | 17 +++--
2 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index 0c6b8a2b..031c7a16 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -207,35 +207,20 @@ class CorrelationResults(object):
elif (self.max_location_mb != None) and (float(trait_object.mb) > float(self.max_location_mb)):
continue
- (trait_object.sample_r,
- trait_object.sample_p,
- trait_object.num_overlap) = self.correlation_data[trait]
-
- # Set some sane defaults
- trait_object.tissue_corr = 0
- trait_object.tissue_pvalue = 0
- trait_object.lit_corr = 0
- if self.corr_type == "tissue" and tissue_corr_data != None:
- trait_object.tissue_corr = tissue_corr_data[trait][1]
- trait_object.tissue_pvalue = tissue_corr_data[trait][2]
- elif self.corr_type == "lit":
- trait_object.lit_corr = lit_corr_data[trait][1]
- self.correlation_results.append(trait_object)
- else:
- (trait_object.sample_r,
- trait_object.sample_p,
- trait_object.num_overlap) = self.correlation_data[trait]
-
- # Set some sane defaults
- trait_object.tissue_corr = 0
- trait_object.tissue_pvalue = 0
- trait_object.lit_corr = 0
- if self.corr_type == "tissue":
- trait_object.tissue_corr = tissue_corr_data[trait][1]
- trait_object.tissue_pvalue = tissue_corr_data[trait][2]
- elif self.corr_type == "lit":
- trait_object.lit_corr = lit_corr_data[trait][1]
- self.correlation_results.append(trait_object)
+ (trait_object.sample_r,
+ trait_object.sample_p,
+ trait_object.num_overlap) = self.correlation_data[trait]
+
+ # Set some sane defaults
+ trait_object.tissue_corr = 0
+ trait_object.tissue_pvalue = 0
+ trait_object.lit_corr = 0
+ if self.corr_type == "tissue" and tissue_corr_data != None:
+ trait_object.tissue_corr = tissue_corr_data[trait][1]
+ trait_object.tissue_pvalue = tissue_corr_data[trait][2]
+ elif self.corr_type == "lit":
+ trait_object.lit_corr = lit_corr_data[trait][1]
+ self.correlation_results.append(trait_object)
self.target_dataset.get_trait_info(self.correlation_results, self.target_dataset.group.species)
@@ -473,13 +458,16 @@ class CorrelationResults(object):
if not value.strip().lower() == 'x':
self.sample_data[str(sample)] = float(value)
-def generate_corr_json(corr_results, this_trait, dataset, target_dataset):
+def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_api = False):
results_list = []
for i, trait in enumerate(corr_results):
results_dict = {}
- results_dict['checkbox'] = ""
- results_dict['index'] = i + 1
- results_dict['trait_id'] = ""+str(trait.name)+""
+ if not for_api:
+ results_dict['checkbox'] = ""
+ results_dict['index'] = i + 1
+ results_dict['trait_id'] = ""+str(trait.name)+""
+ else:
+ results_dict['trait_id'] = trait.name
if target_dataset.type == "ProbeSet":
results_dict['symbol'] = trait.symbol
results_dict['description'] = trait.description_display
@@ -494,7 +482,10 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset):
results_dict['additive'] = "%0.3f" % float(trait.additive)
else:
results_dict['additive'] = "N/A"
- results_dict['sample_r'] = "" + "%0.3f" % float(trait.sample_r) + ""
+ if for_api:
+ results_dict['sample_r'] = "%0.3f" % float(trait.sample_r)
+ else:
+ results_dict['sample_r'] = "" + "%0.3f" % float(trait.sample_r) + ""
results_dict['num_overlap'] = trait.num_overlap
results_dict['sample_p'] = "%0.3e" % float(trait.sample_p)
if trait.lit_corr == "" or trait.lit_corr == 0:
@@ -509,21 +500,35 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset):
results_dict['description'] = trait.description_display
results_dict['authors'] = trait.authors
if trait.pubmed_id:
- results_dict['pubmed'] = " " + trait.pubmed_text + ""
+ if for_api:
+ results_dict['pubmed_id'] = trait.pubmed_id
+ results_dict['year'] = trait.pubmed_text
+ else:
+ results_dict['pubmed'] = " " + trait.pubmed_text + ""
else:
- results_dict['pubmed'] = "N/A"
+ if for_api:
+ results_dict['pubmed_id'] = "N/A"
+ results_dict['year'] = "N/A"
+ else:
+ results_dict['pubmed'] = "N/A"
results_dict['lrs_score'] = trait.LRS_score_repr
results_dict['lrs_location'] = trait.LRS_location_repr
if trait.additive != "":
results_dict['additive'] = "%0.3f" % float(trait.additive)
else:
results_dict['additive'] = "N/A"
- results_dict['sample_r'] = "" + "%0.3f" % trait.sample_r + ""
+ if for_api:
+ results_dict['sample_r'] = "%0.3f" % trait.sample_r
+ else:
+ results_dict['sample_r'] = "" + "%0.3f" % trait.sample_r + ""
results_dict['num_overlap'] = trait.num_overlap
results_dict['sample_p'] = "%0.3e" % float(trait.sample_p)
else:
results_dict['lrs_location'] = trait.LRS_location_repr
- results_dict['sample_r'] = "" + "%0.3f" % float(trait.sample_r) + ""
+ if for_api:
+ results_dict['sample_r'] = "%0.3f" % trait.sample_r
+ else:
+ results_dict['sample_r'] = "" + "%0.3f" % float(trait.sample_r) + ""
results_dict['num_overlap'] = trait.num_overlap
results_dict['sample_p'] = "%0.3e" % float(trait.sample_p)
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index f4d5ca66..67cefaa6 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -346,9 +346,12 @@ class DisplayMappingResults(object):
thisTrait = self.this_trait
_strains, _vals, _vars, _aliases = thisTrait.export_informative()
smd=[]
- for ii, _val in enumerate(_vals):
- temp = GeneralObject(name=_strains[ii], value=_val)
- smd.append(temp)
+ for ii, _val in enumerate(self.vals):
+ if _val != "x":
+ temp = GeneralObject(name=self.samples[ii], value=float(_val))
+ smd.append(temp)
+ else:
+ continue
samplelist = list(self.genotype.prgy)
for j,_geno in enumerate (self.genotype[0][1].genotype):
for item in smd:
@@ -1167,10 +1170,12 @@ class DisplayMappingResults(object):
_strains, _vals, _vars, _aliases = thisTrait.export_informative()
smd=[]
- for ii, _val in enumerate(_vals):
- if _strains[ii] in self.samples:
- temp = GeneralObject(name=_strains[ii], value=_val)
+ for ii, _val in enumerate(self.vals):
+ if _val != "x":
+ temp = GeneralObject(name=self.samples[ii], value=float(_val))
smd.append(temp)
+ else:
+ continue
smd.sort(lambda A, B: cmp(A.value, B.value))
smd.reverse()
--
cgit v1.2.3