From 7938d8c6cbdfe866ebf9ec62dec0fe5c43cf2d6f Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 12 Jun 2013 22:45:57 +0000 Subject: Fixed a couple issues with the template that caused the regular search results and show trait page to not display --- wqflask/base/data_set.py | 4 +- wqflask/wqflask/search_results.py | 59 +++++---- wqflask/wqflask/templates/index_page.html | 9 +- wqflask/wqflask/templates/quick_search.html | 146 ++++++++++++++++++---- wqflask/wqflask/templates/show_trait_details.html | 4 +- 5 files changed, 165 insertions(+), 57 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index d7328441..9b0a3dcc 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -735,8 +735,10 @@ class MrnaAssayDataSet(DataSet): trait_location_value = 1000000 if this_trait.chr and this_trait.mb: + print("this_trait.chr is:", this_trait.chr) + print("this_trait.mb is:", this_trait.mb) try: - trait_location_value = int(this_trait.chr)*1000 + this_trait.mb + trait_location_value = float(this_trait.chr)*1000 + float(this_trait.mb) except: if this_trait.chr.upper() == 'X': trait_location_value = 20*1000 + this_trait.mb diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index ad74f6cc..63aa481e 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -42,7 +42,7 @@ from utility import formatting #def __init__(self, key, result_fields): # self.key = key # self.result_fields = result_fields - + class SearchResultPage(object): #maxReturn = 3000 @@ -73,6 +73,7 @@ class SearchResultPage(object): self.quick = True self.search_terms = kw['q'] print("self.search_terms is: ", self.search_terms) + self.trait_type = kw['trait_type'] self.quick_search() else: self.results = [] @@ -91,7 +92,7 @@ class SearchResultPage(object): """ self.trait_list = [] - + species = webqtlDatabaseFunction.retrieve_species(self.dataset.group.name) # result_set represents the results for each search term; a search of @@ -100,7 +101,7 @@ class SearchResultPage(object): for result in self.results: if not result: continue - + #### Excel file needs to be generated #### print("foo locals are:", locals()) @@ -123,42 +124,46 @@ class SearchResultPage(object): FROM QuickSearch WHERE MATCH (terms) AGAINST ('{}' IN BOOLEAN MODE) """.format(search_terms) - #print("query is: ", query) with Bench("Doing QuickSearch Query: "): dbresults = g.db.execute(query, no_parameters=True).fetchall() #print("results: ", pf(results)) - + self.results = collections.defaultdict(list) - + type_dict = {'PublishXRef': 'phenotype', 'ProbeSetXRef': 'mrna_assay', 'GenoXRef': 'genotype'} - + self.species_groups = {} + for dbresult in dbresults: this_result = {} this_result['table_name'] = dbresult.table_name - this_result['key'] = dbresult.the_key - this_result['result_fields'] = json.loads(dbresult.result_fields) - this_species = this_result['result_fields']['species'] - this_group = this_result['result_fields']['group_name'] - if this_species not in self.species_groups: - self.species_groups[this_species] = {} - if type_dict[dbresult.table_name] not in self.species_groups[this_species]: - self.species_groups[this_species][type_dict[dbresult.table_name]] = [] - if this_group not in self.species_groups[this_species][type_dict[dbresult.table_name]]: - self.species_groups[this_species][type_dict[dbresult.table_name]].append(this_group) - #if type_dict[dbresult.table_name] not in self.species_groups: - # self.species_groups[type_dict[dbresult.table_name]] = {} - #if this_species not in self.species_groups[type_dict[dbresult.table_name]]: - # self.species_groups[type_dict[dbresult.table_name]][this_species] = [] - #if this_group not in self.species_groups[type_dict[dbresult.table_name]][this_species]: - # self.species_groups[type_dict[dbresult.table_name]][this_species].append(this_group) - self.results[type_dict[dbresult.table_name]].append(this_result) - - #print("results: ", pf(self.results['phenotype'])) - + if self.trait_type == type_dict[dbresult.table_name] or self.trait_type == 'all': + this_result['key'] = dbresult.the_key + this_result['result_fields'] = json.loads(dbresult.result_fields) + this_species = this_result['result_fields']['species'] + this_group = this_result['result_fields']['group_name'] + if this_species not in self.species_groups: + self.species_groups[this_species] = {} + if type_dict[dbresult.table_name] not in self.species_groups[this_species]: + self.species_groups[this_species][type_dict[dbresult.table_name]] = [] + if this_group not in self.species_groups[this_species][type_dict[dbresult.table_name]]: + self.species_groups[this_species][type_dict[dbresult.table_name]].append(this_group) + #if type_dict[dbresult.table_name] not in self.species_groups: + # self.species_groups[type_dict[dbresult.table_name]] = {} + #if this_species not in self.species_groups[type_dict[dbresult.table_name]]: + # self.species_groups[type_dict[dbresult.table_name]][this_species] = [] + #if this_group not in self.species_groups[type_dict[dbresult.table_name]][this_species]: + # self.species_groups[type_dict[dbresult.table_name]][this_species].append(this_group) + self.results[type_dict[dbresult.table_name]].append(this_result) + + import redis + Redis = redis.Redis() + + + #def get_group_species_tree(self): # self.species_groups = collections.default_dict(list) # for key in self.results: diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index b4376ce3..a9f2cb24 100644 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -32,7 +32,14 @@