aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/gen_select_dataset.py
diff options
context:
space:
mode:
authorZachary Sloan2013-08-07 18:39:09 -0500
committerZachary Sloan2013-08-07 18:39:09 -0500
commit8993b25262b7fc565c1be3548660a66afd4c3530 (patch)
treef04ee0f8c61ade5702f8561fc9fbf0e0594d47c9 /wqflask/maintenance/gen_select_dataset.py
parentcf42e71c07efc772c15956b75db374f0f2849cac (diff)
downloadgenenetwork2-8993b25262b7fc565c1be3548660a66afd4c3530.tar.gz
Fixed things with the dataset dropdowns and mRNA datasets
Improved the templates for a couple pages related to changing user password, etc
Diffstat (limited to 'wqflask/maintenance/gen_select_dataset.py')
-rw-r--r--wqflask/maintenance/gen_select_dataset.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py
index d4e47327..ad560659 100644
--- a/wqflask/maintenance/gen_select_dataset.py
+++ b/wqflask/maintenance/gen_select_dataset.py
@@ -99,12 +99,14 @@ def get_groups(species):
def get_types(groups):
"""Build types list"""
types = {}
+ print("Groups: ", pf(groups))
for species, group_dict in groups.iteritems():
types[species] = {}
for group_name, _group_full_name in group_dict:
# make group an alias to shorten the code
types[species][group_name] = [("Phenotypes", "Phenotypes"), ("Genotypes", "Genotypes")]
types[species][group_name] += build_types(species, group_name)
+
return types
@@ -115,7 +117,17 @@ def build_types(species, group):
(all types except phenotype/genotype are tissues)
"""
- Cursor.execute("""select distinct Tissue.Name, concat(Tissue.Name, ' mRNA')
+
+ print("""select distinct Tissue.Name
+ from ProbeFreeze, ProbeSetFreeze, InbredSet, Tissue, Species
+ where Species.Name = '{}' and Species.Id = InbredSet.SpeciesId and
+ InbredSet.Name = '{}' and
+ ProbeFreeze.TissueId = Tissue.Id and
+ ProbeFreeze.InbredSetId = InbredSet.Id and
+ ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and
+ ProbeSetFreeze.public > 0
+ order by Tissue.Name""".format(species, group))
+ Cursor.execute("""select distinct Tissue.Name
from ProbeFreeze, ProbeSetFreeze, InbredSet, Tissue, Species
where Species.Name = %s and Species.Id = InbredSet.SpeciesId and
InbredSet.Name = %s and
@@ -124,8 +136,13 @@ def build_types(species, group):
ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and
ProbeSetFreeze.public > 0
order by Tissue.Name""", (species, group))
- return Cursor.fetchall()
-
+
+ results = []
+ for result in Cursor.fetchall():
+ if len(result):
+ results.append((result[0], result[0]))
+
+ return results
def get_datasets(types):
"""Build datasets list"""
@@ -133,9 +150,10 @@ def get_datasets(types):
for species, group_dict in types.iteritems():
datasets[species] = {}
for group, type_list in group_dict.iteritems():
+ print("type_list: ", type_list)
datasets[species][group] = {}
- for type_name, _type_full_name in type_list:
- datasets[species][group][type_name] = build_datasets(species, group, type_name)
+ for type_name in type_list:
+ datasets[species][group][type_name[0]] = build_datasets(species, group, type_name[0])
return datasets
@@ -156,6 +174,14 @@ def build_datasets(species, group, type_name):
if dataset_value:
return [(dataset_value, dataset_text)]
else:
+ print("""select ProbeSetFreeze.Name, ProbeSetFreeze.FullName from
+ ProbeSetFreeze, ProbeFreeze, InbredSet, Tissue, Species where
+ Species.Name = '{}' and Species.Id = InbredSet.SpeciesId and
+ InbredSet.Name = '{}' and
+ ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and Tissue.Name = '{}'
+ and ProbeFreeze.TissueId = Tissue.Id and ProbeFreeze.InbredSetId =
+ InbredSet.Id and ProbeSetFreeze.public > 0 order by
+ ProbeSetFreeze.CreateTime desc""".format(species, group, type_name))
Cursor.execute("""select ProbeSetFreeze.Name, ProbeSetFreeze.FullName from
ProbeSetFreeze, ProbeFreeze, InbredSet, Tissue, Species where
Species.Name = %s and Species.Id = InbredSet.SpeciesId and
@@ -163,8 +189,7 @@ def build_datasets(species, group, type_name):
ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and Tissue.Name = %s
and ProbeFreeze.TissueId = Tissue.Id and ProbeFreeze.InbredSetId =
InbredSet.Id and ProbeSetFreeze.public > 0 order by
- ProbeSetFreeze.CreateTime desc""", (
- species, group, type_name))
+ ProbeSetFreeze.CreateTime desc""", (species, group, type_name))
return Cursor.fetchall()