aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/gen_select_dataset.py
diff options
context:
space:
mode:
authorpjotrp2015-11-18 11:19:01 +0100
committerpjotrp2015-11-18 11:19:01 +0100
commitcb0f10fc4850b6b06f2237b532317a5c6668584a (patch)
treed143662ecceac5e05bd06afee4c87b2beb88859b /wqflask/maintenance/gen_select_dataset.py
parent28ec342362ba068b3d0b5b9a302bc279d251f160 (diff)
parent0310301b30c59eca45235cd1bd1ff8e15923950a (diff)
downloadgenenetwork2-cb0f10fc4850b6b06f2237b532317a5c6668584a.tar.gz
Merge branch 'master' of https://github.com/zsloan/genenetwork2 into zsloan
Diffstat (limited to 'wqflask/maintenance/gen_select_dataset.py')
-rwxr-xr-xwqflask/maintenance/gen_select_dataset.py52
1 files changed, 45 insertions, 7 deletions
diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py
index 694efeca..a2ad8c91 100755
--- a/wqflask/maintenance/gen_select_dataset.py
+++ b/wqflask/maintenance/gen_select_dataset.py
@@ -35,7 +35,9 @@ from __future__ import print_function, division
#config = config.Config(cdict).from_envvar('WQFLASK_SETTINGS')
#print("cdict is:", cdict)
-import our_settings
+import sys
+sys.path.append("/home/zas1024/")
+import zach_settings
import MySQLdb
@@ -47,7 +49,7 @@ import urlparse
from pprint import pformat as pf
-#Engine = sa.create_engine(our_settings.SQLALCHEMY_DATABASE_URI)
+#Engine = sa.create_engine(zach_settings.SQLALCHEMY_DATABASE_URI)
# build MySql database connection
@@ -60,7 +62,7 @@ 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(our_settings.DB_URI)
+ parsed_uri = urlparse.urlparse(zach_settings.DB_URI)
db_conn_info = dict(
db = parsed_uri.path[1:],
@@ -104,12 +106,48 @@ def get_types(groups):
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)
+ #types[species][group_name] = [("Phenotypes", "Phenotypes"), ("Genotypes", "Genotypes")]
+ if phenotypes_exist(group_name):
+ types[species][group_name] = [("Phenotypes", "Phenotypes")]
+ if genotypes_exist(group_name):
+ if group_name in types[species]:
+ types[species][group_name] += [("Genotypes", "Genotypes")]
+ else:
+ types[species][group_name] = [("Genotypes", "Genotypes")]
+ if group_name in types[species]:
+ types[species][group_name] += build_types(species, group_name)
+ else:
+ types[species][group_name] = build_types(species, group_name)
return types
+def phenotypes_exist(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)
+
+ if results != None:
+ return True
+ else:
+ return False
+
+def genotypes_exist(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)
+
+ if results != None:
+ return True
+ else:
+ return False
+
def build_types(species, group):
"""Fetches tissues
@@ -196,7 +234,7 @@ def build_datasets(species, group, type_name):
def main():
"""Generates and outputs (as json file) the data for the main dropdown menus on the home page"""
- parse_db_uri(our_settings.DB_URI)
+ parse_db_uri(zach_settings.DB_URI)
species = get_species()
groups = get_groups(species)
@@ -236,6 +274,6 @@ def _test_it():
#print("build_datasets:", pf(datasets))
if __name__ == '__main__':
- Conn = MySQLdb.Connect(**parse_db_uri(our_settings.DB_URI))
+ Conn = MySQLdb.Connect(**parse_db_uri(zach_settings.DB_URI))
Cursor = Conn.cursor()
main()