aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance
diff options
context:
space:
mode:
authorzsloan2015-05-11 21:33:40 +0000
committerzsloan2015-05-11 21:33:40 +0000
commit54ed7ea5e72d59e0f17db4893ecbaca3dfca151a (patch)
tree4b8a46dbe35219118c450cf03f175049c9c2b6a1 /wqflask/maintenance
parenta53d68ebcc53f02886b7a0d9d65da490a36c916b (diff)
downloadgenenetwork2-54ed7ea5e72d59e0f17db4893ecbaca3dfca151a.tar.gz
Fixed gen_select_dataset so that it does not include Phenotype and
Genotype groups when the corresponding data sets do not exist Interval Mapping no longer shows up for human traits Fixed the appearance of the mirror links on the main page
Diffstat (limited to 'wqflask/maintenance')
-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()