aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Tarasov2015-06-18 20:05:49 +0300
committerArtem Tarasov2015-06-18 20:05:49 +0300
commit45ebe51fbee7da1617b01cff7b9ab404d6ad1aa7 (patch)
tree33e2e5a0de9f080db3fb9a38e77aa318637a034a
parente4621a2a759f55659b5c631baec5e5f497e0cff1 (diff)
downloadgenenetwork2-45ebe51fbee7da1617b01cff7b9ab404d6ad1aa7.tar.gz
fix all_samples_ordered
move duplicated code into a method, handle the case of missing f1/f12 correctly
-rwxr-xr-xwqflask/base/data_set.py6
-rwxr-xr-xwqflask/base/trait.py9
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py9
3 files changed, 8 insertions, 16 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index acfee3d4..b17396e5 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -392,6 +392,12 @@ class DatasetGroup(object):
Redis.set(key, json.dumps(self.samplelist))
Redis.expire(key, 60*5)
+ def all_samples_ordered(self):
+ result = []
+ lists = (self.parlist, self.f1list, self.samplelist)
+ [result.extend(l) for l in lists if l]
+ return result
+
def read_genotype_file(self):
'''Read genotype from .geno file instead of database'''
#if self.group == 'BXD300':
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 7f1170a9..2e0e86fb 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -251,14 +251,7 @@ class GeneralTrait(object):
# Todo: is this necessary? If not remove
self.data.clear()
- if self.dataset.group.parlist:
- all_samples_ordered = (self.dataset.group.parlist +
- self.dataset.group.f1list +
- self.dataset.group.samplelist)
- elif self.dataset.group.f1list:
- all_samples_ordered = self.dataset.group.f1list + self.dataset.group.samplelist
- else:
- all_samples_ordered = self.dataset.group.samplelist
+ all_samples_ordered = self.dataset.group.all_samples_ordered()
if results:
for item in results:
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index bd827086..61305e9b 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -1148,14 +1148,7 @@ class ShowTrait(object):
def make_sample_lists(self, this_trait):
- if self.dataset.group.parlist:
- all_samples_ordered = (self.dataset.group.parlist +
- self.dataset.group.f1list +
- self.dataset.group.samplelist)
- elif self.dataset.group.f1list:
- all_samples_ordered = self.dataset.group.f1list + self.dataset.group.samplelist
- else:
- all_samples_ordered = list(self.dataset.group.samplelist)
+ all_samples_ordered = self.dataset.group.all_samples_ordered()
primary_sample_names = list(all_samples_ordered)