aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/gen_select_dataset.py
diff options
context:
space:
mode:
authorzsloan2016-06-20 16:01:12 +0000
committerzsloan2016-06-20 16:01:12 +0000
commit30a37c6f1f9a9f759a92fd61876af9e9e3d078b9 (patch)
treee4f5b49aa21c32aa2b770b1a65c8fef7782b625f /wqflask/maintenance/gen_select_dataset.py
parent4fec0e6fc0772785a30451d417082bc189f2f6dd (diff)
parent10df36b60273d81678f6630c07a2d8e5a6409282 (diff)
downloadgenenetwork2-30a37c6f1f9a9f759a92fd61876af9e9e3d078b9.tar.gz
Merge branch 'staging' of github.com:genenetwork/genenetwork2 into development
Diffstat (limited to 'wqflask/maintenance/gen_select_dataset.py')
-rwxr-xr-xwqflask/maintenance/gen_select_dataset.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py
index 489d291f..b1459bf3 100755
--- a/wqflask/maintenance/gen_select_dataset.py
+++ b/wqflask/maintenance/gen_select_dataset.py
@@ -21,7 +21,7 @@ It needs to be run manually when database has been changed.
# (sourceforge.net/projects/genenetwork/).
#
# Contact Drs. Robert W. Williams
-# at rwilliams@uthsc.edu
+# at rwilliams@uthsc.edu
#
#
#
@@ -60,15 +60,15 @@ from pprint import pformat as pf
def parse_db_uri(db_uri):
"""Converts a database URI to the db name, host name, user name, and password"""
-
+
parsed_uri = urlparse.urlparse(zach_settings.DB_URI)
-
+
db_conn_info = dict(
db = parsed_uri.path[1:],
host = parsed_uri.hostname,
user = parsed_uri.username,
passwd = parsed_uri.password)
-
+
return db_conn_info
@@ -149,12 +149,12 @@ def genotypes_exist(group_name):
def build_types(species, group):
"""Fetches tissues
-
+
Gets the tissues with data for this species/group
(all types except phenotype/genotype are tissues)
-
+
"""
-
+
Cursor.execute("""select distinct Tissue.Name
from ProbeFreeze, ProbeSetFreeze, InbredSet, Tissue, Species
where Species.Name = %s and Species.Id = InbredSet.SpeciesId and
@@ -164,14 +164,14 @@ def build_types(species, group):
ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and
ProbeSetFreeze.public > 0
order by Tissue.Name""", (species, group))
-
+
results = []
for result in Cursor.fetchall():
if len(result):
these_datasets = build_datasets(species, group, result[0])
if len(these_datasets) > 0:
results.append((result[0], result[0]))
-
+
return results
def get_datasets(types):
@@ -196,10 +196,10 @@ def build_datasets(species, group, type_name):
if type_name == "Phenotypes":
print("GROUP:", group)
Cursor.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where
- InbredSet.Name = %s and
+ InbredSet.Name = %s and
PublishFreeze.InbredSetId = InbredSet.Id and
InfoFiles.InfoPageName = PublishFreeze.Name and
- PublishFreeze.public > 0 and
+ PublishFreeze.public > 0 and
PublishFreeze.confidentiality < 1 order by
PublishFreeze.CreateTime desc""", (group))
@@ -216,10 +216,10 @@ def build_datasets(species, group, type_name):
elif type_name == "Genotypes":
Cursor.execute("""select InfoFiles.GN_AccesionId from InfoFiles, GenoFreeze, InbredSet where
- InbredSet.Name = %s and
+ InbredSet.Name = %s and
GenoFreeze.InbredSetId = InbredSet.Id and
InfoFiles.InfoPageName = GenoFreeze.ShortName and
- GenoFreeze.public > 0 and
+ GenoFreeze.public > 0 and
GenoFreeze.confidentiality < 1 order by
GenoFreeze.CreateTime desc""", (group))
@@ -238,11 +238,11 @@ def build_datasets(species, group, type_name):
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.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))
-
+
dataset_results = Cursor.fetchall()
datasets = []
for dataset_info in dataset_results:
@@ -295,7 +295,7 @@ def _test_it():
datasets = build_datasets("Mouse", "BXD", "Hippocampus")
#print("build_datasets:", pf(datasets))
-if __name__ == '__main__':
+if __name__ == '__main__':
Conn = MySQLdb.Connect(**parse_db_uri(zach_settings.DB_URI))
Cursor = Conn.cursor()
main()