diff options
-rw-r--r-- | wqflask/base/data_set.py | 41 | ||||
-rw-r--r-- | wqflask/wqflask/__init__.py | 4 | ||||
-rw-r--r-- | wqflask/wqflask/api/gen_menu.py | 18 | ||||
-rw-r--r-- | wqflask/wqflask/collect.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js | 1 |
5 files changed, 28 insertions, 38 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 1f99df49..fd1dff5c 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -93,22 +93,26 @@ Publish or ProbeSet. E.g. """ self.datasets = {} - data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown").content) - #data = gen_menu.gen_dropdown_json() - - - for species in data['datasets']: - for group in data['datasets'][species]: - for dataset_type in data['datasets'][species][group]: - for dataset in data['datasets'][species][group][dataset_type]: - short_dataset_name = dataset[1] - if dataset_type == "Phenotypes": - new_type = "Publish" - elif dataset_type == "Genotypes": - new_type = "Geno" - else: - new_type = "ProbeSet" - self.datasets[short_dataset_name] = new_type + + data = Redis.get("dataset_structure") + if data: + self.datasets = json.loads(data) + else: #ZS: I don't think this should ever run unless Redis is emptied + data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown").content) + for species in data['datasets']: + for group in data['datasets'][species]: + for dataset_type in data['datasets'][species][group]: + for dataset in data['datasets'][species][group][dataset_type]: + short_dataset_name = dataset[1] + if dataset_type == "Phenotypes": + new_type = "Publish" + elif dataset_type == "Genotypes": + new_type = "Geno" + else: + new_type = "ProbeSet" + self.datasets[short_dataset_name] = new_type + + Redis.set("dataset_structure", json.dumps(self.datasets)) # Set LOG_LEVEL_DEBUG=5 to see the following: logger.debugf(5, "datasets",self.datasets) @@ -127,6 +131,7 @@ Publish or ProbeSet. E.g. results = g.db.execute(geno_query).fetchall() if len(results): self.datasets[name] = "ProbeSet" + Redis.set("dataset_structure", json.dumps(self.datasets)) return self.datasets[name] group_name = name.replace("Publish", "") @@ -140,6 +145,7 @@ Publish or ProbeSet. E.g. results = g.db.execute(pheno_query).fetchall() if len(results): self.datasets[name] = "Publish" + Redis.set("dataset_structure", json.dumps(self.datasets)) return self.datasets[name] #ZS: For when there isn't an InfoFiles ID; not sure if this and the preceding query are both necessary @@ -151,6 +157,7 @@ Publish or ProbeSet. E.g. results = g.db.execute(other_pheno_query).fetchall() if len(results): self.datasets[name] = "Publish" + Redis.set("dataset_structure", json.dumps(self.datasets)) return self.datasets[name] geno_query = """ @@ -166,11 +173,11 @@ Publish or ProbeSet. E.g. results = g.db.execute(geno_query).fetchall() if len(results): self.datasets[name] = "Geno" + Redis.set("dataset_structure", json.dumps(self.datasets)) return self.datasets[name] #ZS: It shouldn't ever reach this return None - else: return self.datasets[name] diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index 399e794d..62e98b36 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -21,5 +21,5 @@ app.jinja_env.globals.update( numify = formatting.numify ) -import wqflask.views -from wqflask.api import router
\ No newline at end of file +from wqflask.api import router +import wqflask.views
\ No newline at end of file diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py index adf66fb5..c7bcb65d 100644 --- a/wqflask/wqflask/api/gen_menu.py +++ b/wqflask/wqflask/api/gen_menu.py @@ -1,7 +1,6 @@ from __future__ import print_function, division import sys -import json from flask import g @@ -23,14 +22,6 @@ def gen_dropdown_json(): types = get_types(groups) datasets = get_datasets(types) - #species.append(('All Species', 'All Species')) - #groups['All Species'] = [('All Groups', 'All Groups')] - #types['All Species'] = {} - #types['All Species']['All Groups'] = [('Phenotypes', 'Phenotypes')] - #datasets['All Species'] = {} - #datasets['All Species']['All Groups'] = {} - #datasets['All Species']['All Groups']['Phenotypes'] = [('All Phenotypes','All Phenotypes')] - data = dict(species=species, groups=groups, types=types, @@ -55,15 +46,6 @@ def get_groups(species): groups = {} for species_name, _species_full_name in species: groups[species_name] = [] - # results = g.db.execute("""SELECT InbredSet.Name, InbredSet.FullName - # FROM InbredSet, Species, ProbeFreeze, GenoFreeze, PublishFreeze - # WHERE Species.Name = '{}' AND - # InbredSet.SpeciesId = Species.Id AND - # (PublishFreeze.InbredSetId = InbredSet.Id OR - # GenoFreeze.InbredSetId = InbredSet.Id OR - # ProbeFreeze.InbredSetId = InbredSet.Id) - # GROUP by InbredSet.Name - # ORDER BY InbredSet.FullName""".format(species_name)).fetchall() results = g.db.execute("""SELECT InbredSet.Name, InbredSet.FullName, IFNULL(InbredSet.Family, 'None') FROM InbredSet, Species diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 1d74b699..b22e0004 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -185,7 +185,7 @@ def delete_collection(): if len(uc_id.split(":")) > 1: flash("We've deleted the selected collections.", "alert-info") else: - flash("We've deleted the collection: {}.".format(uc_id), "alert-info") + flash("We've deleted the selected collection.", "alert-info") else: flash("We've deleted the collection: {}.".format(collection_name), "alert-info") diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index 794804f4..ee7be68c 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -6,6 +6,7 @@ process_json = function(data) { return apply_default(); } }; + $.ajax('/api/v_pre1/gen_dropdown', { dataType: 'json', success: process_json |