aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/gen_select_dataset.py
diff options
context:
space:
mode:
authorLei Yan2016-02-25 16:42:15 +0000
committerLei Yan2016-02-25 16:42:15 +0000
commite55f38a72d47fbdf5f652a08e8da1db78f1dcdb5 (patch)
tree68161b76858cf72f7a7b5576de6384042e214d8e /wqflask/maintenance/gen_select_dataset.py
parent7263c52a7d903a2dbdd5d05411821ec960961b4d (diff)
parentece60a2d25ed71980121ac1c1854c3ab3514f453 (diff)
downloadgenenetwork2-e55f38a72d47fbdf5f652a08e8da1db78f1dcdb5.tar.gz
Merge /home/zas1024/gene
Diffstat (limited to 'wqflask/maintenance/gen_select_dataset.py')
-rwxr-xr-xwqflask/maintenance/gen_select_dataset.py89
1 files changed, 56 insertions, 33 deletions
diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py
index a2ad8c91..e080050e 100755
--- a/wqflask/maintenance/gen_select_dataset.py
+++ b/wqflask/maintenance/gen_select_dataset.py
@@ -76,7 +76,7 @@ def parse_db_uri(db_uri):
def get_species():
"""Build species list"""
- Cursor.execute("select Name, MenuName from Species order by OrderId")
+ Cursor.execute("select Name, MenuName from Species where Species.Name != 'macaque monkey' order by OrderId")
species = list(Cursor.fetchall())
return species
@@ -90,8 +90,8 @@ def get_groups(species):
ProbeFreeze, GenoFreeze, PublishFreeze where Species.Name = %s
and InbredSet.SpeciesId = Species.Id and InbredSet.Name != 'BXD300' and
(PublishFreeze.InbredSetId = InbredSet.Id
- or GenoFreeze.InbredSetId = InbredSet.Id
- or ProbeFreeze.InbredSetId = InbredSet.Id)
+ or GenoFreeze.InbredSetId = InbredSet.Id
+ or ProbeFreeze.InbredSetId = InbredSet.Id)
group by InbredSet.Name
order by InbredSet.Name""", (species_name))
groups[species_name] = list(Cursor.fetchall())
@@ -123,12 +123,12 @@ def get_types(groups):
def phenotypes_exist(group_name):
- print("group_name:", group_name)
+ #print("group_name:", group_name)
Cursor.execute("""select Name from PublishFreeze
where PublishFreeze.Name = %s""", (group_name+"Publish"))
results = Cursor.fetchone()
- print("RESULTS:", results)
+ #print("RESULTS:", results)
if results != None:
return True
@@ -136,12 +136,12 @@ def phenotypes_exist(group_name):
return False
def genotypes_exist(group_name):
- print("group_name:", group_name)
+ #print("group_name:", group_name)
Cursor.execute("""select Name from GenoFreeze
where GenoFreeze.Name = %s""", (group_name+"Geno"))
results = Cursor.fetchone()
- print("RESULTS:", results)
+ #print("RESULTS:", results)
if results != None:
return True
@@ -156,15 +156,6 @@ def build_types(species, group):
"""
- #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
@@ -178,7 +169,9 @@ def build_types(species, group):
results = []
for result in Cursor.fetchall():
if len(result):
- results.append((result[0], result[0]))
+ these_datasets = build_datasets(species, group, result[0])
+ if len(these_datasets) > 0:
+ results.append((result[0], result[0]))
return results
@@ -191,7 +184,10 @@ def get_datasets(types):
#print("type_list: ", type_list)
datasets[species][group] = {}
for type_name in type_list:
- datasets[species][group][type_name[0]] = build_datasets(species, group, type_name[0])
+ these_datasets = build_datasets(species, group, type_name[0])
+ if len(these_datasets) > 0:
+ datasets[species][group][type_name[0]] = these_datasets
+
return datasets
@@ -199,6 +195,20 @@ def build_datasets(species, group, type_name):
"""Gets dataset names from database"""
dataset_text = dataset_value = None
if type_name == "Phenotypes":
+ print("GROUP:", group)
+ Cursor.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where
+ InbredSet.Name = %s and
+ PublishFreeze.InbredSetId = InbredSet.Id and
+ InfoFiles.InfoPageName = PublishFreeze.Name and
+ PublishFreeze.public > 0 and
+ PublishFreeze.confidentiality < 1 order by
+ PublishFreeze.CreateTime desc""", (group))
+
+ results = Cursor.fetchone()
+ if results != None:
+ dataset_id = str(results[0])
+ else:
+ dataset_id = "None"
dataset_value = "%sPublish" % group
if group == 'MDP':
dataset_text = "Mouse Phenome Database"
@@ -206,29 +216,43 @@ def build_datasets(species, group, type_name):
dataset_text = "%s Published Phenotypes" % group
elif type_name == "Genotypes":
+ Cursor.execute("""select InfoFiles.GN_AccesionId from InfoFiles, GenoFreeze, InbredSet where
+ InbredSet.Name = %s and
+ GenoFreeze.InbredSetId = InbredSet.Id and
+ InfoFiles.InfoPageName = GenoFreeze.ShortName and
+ GenoFreeze.public > 0 and
+ GenoFreeze.confidentiality < 1 order by
+ GenoFreeze.CreateTime desc""", (group))
+
+ results = Cursor.fetchone()
+ if results != None:
+ dataset_id = str(results[0])
+ else:
+ dataset_id = "None"
dataset_value = "%sGeno" % group
dataset_text = "%s Genotypes" % group
if dataset_value:
- return [(dataset_value, dataset_text)]
+ return [(dataset_id, 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
+ Cursor.execute("""select ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName from
ProbeSetFreeze, ProbeFreeze, InbredSet, Tissue, Species where
Species.Name = %s and Species.Id = InbredSet.SpeciesId and
InbredSet.Name = %s and
- 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.ProbeFreezeId = ProbeFreeze.Id and Tissue.Name = %s and
+ ProbeFreeze.TissueId = Tissue.Id and ProbeFreeze.InbredSetId = InbredSet.Id and
+ ProbeSetFreeze.confidentiality < 1 and ProbeSetFreeze.public > 0 order by
ProbeSetFreeze.CreateTime desc""", (species, group, type_name))
- return Cursor.fetchall()
+
+ dataset_results = Cursor.fetchall()
+ datasets = []
+ for dataset_info in dataset_results:
+ this_dataset_info = []
+ for info in dataset_info:
+ this_dataset_info.append(str(info))
+ datasets.append(this_dataset_info)
+
+ return datasets
def main():
@@ -238,7 +262,6 @@ def main():
species = get_species()
groups = get_groups(species)
- print("groups:", groups)
types = get_types(groups)
datasets = get_datasets(types)