aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/data_set.py
diff options
context:
space:
mode:
authorArtem Tarasov2015-05-13 11:13:05 +0300
committerArtem Tarasov2015-05-13 11:13:05 +0300
commitd9f617afba9c3881f273902447aef94755a6deee (patch)
tree3534e7fa4c0434ffced96e46707d7ded6ed8549e /wqflask/base/data_set.py
parentbdd29d68872d571f1f3b737d4b45ec4dbe7d5523 (diff)
downloadgenenetwork2-d9f617afba9c3881f273902447aef94755a6deee.tar.gz
cache datasets for each group
Diffstat (limited to 'wqflask/base/data_set.py')
-rwxr-xr-xwqflask/base/data_set.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 1cd57b4b..40c38fe8 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -292,6 +292,7 @@ class DatasetGroup(object):
self.incparentsf1 = False
self.allsamples = None
+ self._datasets = None
def get_specified_markers(self, markers = []):
self.markers = HumanMarkers(self.name, markers)
@@ -305,6 +306,52 @@ class DatasetGroup(object):
self.markers = marker_class(self.name)
+ def datasets(self):
+ key = "group_dataset_menu:v1:" + self.name
+ print("key is:", key)
+ with Bench("Loading cache"):
+ result = Redis.get(key)
+ if result:
+ self._datasets = pickle.loads(result)
+ return self._datasets
+
+ dataset_menu = []
+ print("[tape4] webqtlConfig.PUBLICTHRESH:", webqtlConfig.PUBLICTHRESH)
+ print("[tape4] type webqtlConfig.PUBLICTHRESH:", type(webqtlConfig.PUBLICTHRESH))
+ results = g.db.execute("""SELECT PublishFreeze.FullName,PublishFreeze.Name FROM
+ PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id
+ and InbredSet.Name = %s and PublishFreeze.public > %s""",
+ (self.name, webqtlConfig.PUBLICTHRESH))
+ for item in results.fetchall():
+ dataset_menu.append(dict(tissue=None,
+ datasets=[item]))
+
+ results = g.db.execute("""SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze,
+ InbredSet WHERE GenoFreeze.InbredSetId = InbredSet.Id and InbredSet.Name =
+ %s and GenoFreeze.public > %s""",
+ (self.name, webqtlConfig.PUBLICTHRESH))
+ for item in results.fetchall():
+ dataset_menu.append(dict(tissue=None,
+ datasets=[item]))
+
+ #03/09/2009: Xiaodong changed the SQL query to order by Name as requested by Rob.
+ tissues = g.db.execute("SELECT Id, Name FROM Tissue order by Name")
+ for item in tissues.fetchall():
+ tissue_id, tissue_name = item
+ data_sets = g.db.execute('''SELECT ProbeSetFreeze.FullName,ProbeSetFreeze.Name FROM ProbeSetFreeze, ProbeFreeze,
+ InbredSet WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeFreeze.TissueId = %s and
+ ProbeSetFreeze.public > %s and ProbeFreeze.InbredSetId = InbredSet.Id and InbredSet.Name like %s
+ order by ProbeSetFreeze.CreateTime desc, ProbeSetFreeze.AvgId ''',
+ (tissue_id, webqtlConfig.PUBLICTHRESH, "%" + self.name + "%"))
+ dataset_sub_menu = [item for item in data_sets.fetchall() if item]
+ if dataset_sub_menu:
+ dataset_menu.append(dict(tissue=tissue_name,
+ datasets=dataset_sub_menu))
+
+ Redis.set(key, pickle.dumps(dataset_menu, pickle.HIGHEST_PROTOCOL))
+ Redis.expire(key, 60*5)
+ self._datasets = dataset_menu
+ return self._datasets
def get_f1_parent_strains(self):
try: