aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2020-10-27 18:00:20 -0500
committerGitHub2020-10-27 18:00:20 -0500
commit4dac73ae7f3cabe037e44892a12600f0e4625ca5 (patch)
tree5705fd7a095edc4c1cd85490f00dce4d5a0dc27c
parent05ad2319f96bd9fa3852079bd6f605e1b13d6dd1 (diff)
parenta63528cbae4c9fdb3fffa402fed6cc2fedce02d5 (diff)
downloadgenenetwork2-4dac73ae7f3cabe037e44892a12600f0e4625ca5.tar.gz
Merge pull request #466 from zsloan/show_trait_attributes_fix
Fix issue where attribute values were displayed in the wrong columns
-rw-r--r--wqflask/base/webqtlCaseData.py13
-rw-r--r--wqflask/wqflask/show_trait/SampleList.py18
-rw-r--r--wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js32
3 files changed, 32 insertions, 31 deletions
diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py
index 3cf2d80d..aa55470f 100644
--- a/wqflask/base/webqtlCaseData.py
+++ b/wqflask/base/webqtlCaseData.py
@@ -41,8 +41,6 @@ class webqtlCaseData:
self.this_id = None # Set a sane default (can't be just "id" cause that's a reserved word)
self.outlier = None # Not set to True/False until later
- self.first_attr_col = self.get_first_attr_col()
-
def __repr__(self):
case_data_string = "<webqtlCaseData> "
if self.value is not None:
@@ -80,13 +78,4 @@ class webqtlCaseData:
def display_num_cases(self):
if self.num_cases is not None:
return "%s" % self.num_cases
- return "x"
-
- def get_first_attr_col(self):
- col_num = 4
- if self.variance is not None:
- col_num += 2
- if self.num_cases is not None:
- col_num += 1
-
- return col_num \ No newline at end of file
+ return "x" \ No newline at end of file
diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py
index e7676458..37c1d6d5 100644
--- a/wqflask/wqflask/show_trait/SampleList.py
+++ b/wqflask/wqflask/show_trait/SampleList.py
@@ -8,7 +8,6 @@ from pprint import pformat as pf
from utility import Plot
from utility import Bunch
-
class SampleList(object):
def __init__(self,
dataset,
@@ -68,6 +67,12 @@ class SampleList(object):
self.sample_list.append(sample)
self.se_exists = any(sample.variance for sample in self.sample_list)
+ self.num_cases_exists = any(sample.num_cases for sample in self.sample_list)
+
+ first_attr_col = self.get_first_attr_col()
+ for sample in self.sample_list:
+ sample.first_attr_col = first_attr_col
+
self.do_outliers()
def __repr__(self):
@@ -148,6 +153,15 @@ class SampleList(object):
attribute_values[self.attributes[item.Id].name] = attribute_value
self.sample_attribute_values[sample_name] = attribute_values
+ def get_first_attr_col(self):
+ first_attr_col = 4
+ if self.se_exists:
+ first_attr_col += 2
+ if self.num_cases_exists:
+ first_attr_col += 1
+
+ return first_attr_col
+
def natural_sort(list, key=lambda s: s):
"""
Sort the list into natural alphanumeric order.
@@ -156,4 +170,4 @@ def natural_sort(list, key=lambda s: s):
def convert(text): return int(text) if text.isdigit() else text
return lambda s: [convert(c) for c in re.split('([0-9]+)', key(s))]
sort_key = get_alphanum_key_func(key)
- list.sort(key=sort_key)
+ list.sort(key=sort_key) \ No newline at end of file
diff --git a/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js b/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js
index 49822cd2..5a4f151c 100644
--- a/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js
+++ b/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js
@@ -75,7 +75,7 @@ build_columns = function() {
);
}
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
column_list.push(
{
'title': "<div style='text-align: right;'>N</div>",
@@ -101,7 +101,8 @@ build_columns = function() {
'type': "natural",
'data': null,
'render': function(data, type, row, meta) {
- attr_name = Object.keys(data.extra_attributes).sort((a, b) => (a > b) ? 1 : -1)[meta.col - data.first_attr_col]
+ attr_name = Object.keys(data.extra_attributes).sort()[meta.col - data.first_attr_col]
+
if (attr_name != null && attr_name != undefined){
return data.extra_attributes[attr_name]
} else {
@@ -111,7 +112,6 @@ build_columns = function() {
}
)
}
-
return column_list
}
@@ -132,23 +132,22 @@ var primary_table = $('#samples_primary').DataTable( {
$('td', row).eq(3).addClass("column_name-Value")
if (js_data.se_exists) {
$('td', row).eq(5).addClass("column_name-SE")
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
$('td', row).eq(6).addClass("column_name-num_cases")
} else {
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
$('td', row).eq(4).addClass("column_name-num_cases")
}
}
} else {
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
$('td', row).eq(4).addClass("column_name-num_cases")
}
}
- sorted_key_list = Object.keys(js_data.attributes).sort()
- for (i=0; i < sorted_key_list.length; i++) {
- $('td', row).eq(attribute_start_pos + i + 1).addClass("column_name-" + js_data.attributes[sorted_key_list[i]].name)
- $('td', row).eq(attribute_start_pos + i + 1).attr("style", "text-align: " + js_data.attributes[sorted_key_list[i]].alignment + "; padding-top: 2px; padding-bottom: 0px;")
+ for (i=0; i < attr_keys.length; i++) {
+ $('td', row).eq(attribute_start_pos + i).addClass("column_name-" + js_data.attributes[attr_keys[i]].name)
+ $('td', row).eq(attribute_start_pos + i).attr("style", "text-align: " + js_data.attributes[attr_keys[i]].alignment + "; padding-top: 2px; padding-bottom: 0px;")
}
},
'data': js_data['sample_lists'][0],
@@ -190,23 +189,22 @@ if (js_data.sample_lists.length > 1){
$('td', row).eq(3).addClass("column_name-Value")
if (js_data.se_exists) {
$('td', row).eq(5).addClass("column_name-SE")
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
$('td', row).eq(6).addClass("column_name-num_cases")
} else {
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
$('td', row).eq(4).addClass("column_name-num_cases")
}
}
} else {
- if (js_data.has_num_cases === "true") {
+ if (js_data.has_num_cases === true) {
$('td', row).eq(4).addClass("column_name-num_cases")
}
}
- sorted_key_list = Object.keys(js_data.attributes).sort()
- for (i=0; i < sorted_key_list.length; i++) {
- $('td', row).eq(attribute_start_pos + i + 1).addClass("column_name-" + js_data.attributes[sorted_key_list[i]].name)
- $('td', row).eq(attribute_start_pos + i + 1).attr("style", "text-align: " + js_data.attributes[sorted_key_list[i]].alignment + "; padding-top: 2px; padding-bottom: 0px;")
+ for (i=0; i < attr_keys.length; i++) {
+ $('td', row).eq(attribute_start_pos + i + 1).addClass("column_name-" + js_data.attributes[attr_keys[i]].name)
+ $('td', row).eq(attribute_start_pos + i + 1).attr("style", "text-align: " + js_data.attributes[attr_keys[i]].alignment + "; padding-top: 2px; padding-bottom: 0px;")
}
},
'data': js_data['sample_lists'][1],