From 398174af99d6e50af9e10bbb95f78bcf74388f81 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 24 Feb 2021 21:13:53 +0000 Subject: Committing in-progress changes to replacing trait creation with directly querying for trait attributes --- wqflask/wqflask/search_results.py | 180 +++++++++++++++++++++++--------------- 1 file changed, 108 insertions(+), 72 deletions(-) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index f23c0582..8edf6147 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -4,6 +4,7 @@ from math import * import time import re import requests +from types import SimpleNamespace from pprint import pformat as pf @@ -11,6 +12,7 @@ import json from base.data_set import create_dataset from base.trait import create_trait +from base.webqtlConfig import PUBMEDLINK_URL from wqflask import parser from wqflask import do_search from db import webqtlDatabaseFunction @@ -18,12 +20,15 @@ from db import webqtlDatabaseFunction from flask import Flask, g from utility import hmac, helper_functions +from utility.authentication_tools import check_resource_availability from utility.tools import GN2_BASE_URL from utility.type_checking import is_str from utility.logger import getLogger logger = getLogger(__name__ ) +from utility.benchmark import Bench + class SearchResultPage(object): #maxReturn = 3000 @@ -39,9 +44,7 @@ class SearchResultPage(object): self.uc_id = uuid.uuid4() self.go_term = None - logger.debug("uc_id:", self.uc_id) # contains a unique id - logger.debug("kw is:", kw) # dict containing search terms if kw['search_terms_or']: self.and_or = "or" self.search_terms = kw['search_terms_or'] @@ -70,11 +73,11 @@ class SearchResultPage(object): assert(is_str(kw.get('dataset'))) self.dataset = create_dataset(kw['dataset'], dataset_type) - logger.debug("search_terms:", self.search_terms) #ZS: I don't like using try/except, but it seems like the easiest way to account for all possible bad searches here try: - self.search() + with Bench("Doing Query"): + self.search() except: self.search_term_exists = False @@ -95,83 +98,118 @@ class SearchResultPage(object): trait_list = [] json_trait_list = [] - species = webqtlDatabaseFunction.retrieve_species(self.dataset.group.name) # result_set represents the results for each search term; a search of # "shh grin2b" would have two sets of results, one for each term - logger.debug("self.results is:", pf(self.results)) + + if self.dataset.type == "ProbeSet": + self.header_data_names = ['index', 'display_name', 'symbol', 'description', 'location', 'mean', 'lrs_score', 'lrs_location', 'additive'] + elif self.dataset.type == "Publish": + self.header_data_names = ['index', 'display_name', 'description', 'mean', 'authors', 'pubmed_text', 'lrs_score', 'lrs_location', 'additive'] + elif self.dataset.type == "Geno": + self.header_data_names = ['index', 'display_name', 'location'] for index, result in enumerate(self.results): if not result: continue - #### Excel file needs to be generated #### - trait_dict = {} - trait_id = result[0] - this_trait = create_trait(dataset=self.dataset, name=trait_id, get_qtl_info=True, get_sample_info=False) - if this_trait: - trait_dict['index'] = index + 1 - trait_dict['name'] = this_trait.name - if this_trait.dataset.type == "Publish": - trait_dict['display_name'] = this_trait.display_name + trait_dict['index'] = index + 1 + trait_dict['name'] = result[0] + + #ZS: Check permissions on a trait-by-trait basis for phenotype traits + if self.dataset.type == "Publish": + permissions = check_resource_availability(self.dataset, trait_dict['name']) + if "view" not in permissions['data']: + continue + + trait_dict['display_name'] = result[0] + if self.dataset.type == "Publish": + if self.dataset.group_code: + trait_dict['display_name'] = self.dataset.group_code + "_" + result[0] + + trait_dict['dataset'] = self.dataset.name + trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(trait_dict['name'], trait_dict['dataset'])) + if self.dataset.type == "ProbeSet": + trait_dict['symbol'] = "N/A" + if result[10]: + trait_dict['symbol'] = result[10] + trait_dict['description'] = "N/A" + description_string = result[2] + if str(description_string) != "" and description_string != None: + description_display = description_string + else: + description_display = trait_dict['symbol'] + + target_string = result[3] + if str(target_string) != "" and target_string != None: + description_display = description_display + "; " + target_string.strip() + trait_dict['description'] = description_display + + trait_dict['location'] = "N/A" + if (result[8] != "NULL" and result[8] != "") and (result[9] != 0): + trait_dict['location'] = f"Chr{result[8]}: {float(result[9]):.6f}" + trait_dict['mean'] = "N/A" + trait_dict['additive'] = "N/A" + if result[4] != "" and result[4] != None: + trait_dict['mean'] = f"{result[4]:.3f}" + try: + trait_dict['lod_score'] = f"{float(result[5]) / 4.61:.1f}" + except: + trait_dict['lod_score'] = "N/A" + try: + trait_dict['lrs_location'] = f"Chr{result[12]}: {float(result[13]):.6f}" + except: + trait_dict['lrs_location'] = "N/A" + if result[5] != "": + trait_dict['additive'] = f"{result[7]:.3f}" + elif self.dataset.type == "Geno": + trait_dict['location'] = "N/A" + if (result[4] != "NULL" and result[4] != "") and (result[5] != 0): + trait_dict['location'] = f"Chr{result[4]}: {float(result[5]):.6f}" + elif self.dataset.type == "Publish": + trait_dict['description'] = "N/A" + trait_dict['pubmed_id'] = "N/A" + trait_dict['pubmed_link'] = "N/A" + trait_dict['pubmed_text'] = "N/A" + trait_dict['mean'] = "N/A" + trait_dict['additive'] = "N/A" + pre_pub_description = result[2].strip() + post_pub_description = result[3].strip() + if result[1] != "NULL" and result[1] != None: + trait_dict['pubmed_id'] = result[1] + trait_dict['pubmed_link'] = PUBMEDLINK_URL % trait_dict['pubmed_id'] + trait_dict['description'] = post_pub_description else: - trait_dict['display_name'] = this_trait.name - trait_dict['dataset'] = this_trait.dataset.name - trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name)) - if this_trait.dataset.type == "ProbeSet": - trait_dict['symbol'] = this_trait.symbol - trait_dict['description'] = "N/A" - if this_trait.description_display: - trait_dict['description'] = this_trait.description_display - trait_dict['location'] = this_trait.location_repr - trait_dict['mean'] = "N/A" - trait_dict['additive'] = "N/A" - if this_trait.mean != "" and this_trait.mean != None: - trait_dict['mean'] = f"{this_trait.mean:.3f}" - try: - trait_dict['lod_score'] = f"{float(this_trait.LRS_score_repr) / 4.61:.1f}" - except: - trait_dict['lod_score'] = "N/A" - trait_dict['lrs_location'] = this_trait.LRS_location_repr - if this_trait.additive != "": - trait_dict['additive'] = f"{this_trait.additive:.3f}" - elif this_trait.dataset.type == "Geno": - trait_dict['location'] = this_trait.location_repr - elif this_trait.dataset.type == "Publish": - trait_dict['description'] = "N/A" - if this_trait.description_display: - trait_dict['description'] = this_trait.description_display - trait_dict['authors'] = this_trait.authors - trait_dict['pubmed_id'] = "N/A" - if this_trait.pubmed_id: - trait_dict['pubmed_id'] = this_trait.pubmed_id - trait_dict['pubmed_link'] = this_trait.pubmed_link - trait_dict['pubmed_text'] = this_trait.pubmed_text - trait_dict['mean'] = "N/A" - if this_trait.mean != "" and this_trait.mean != None: - trait_dict['mean'] = f"{this_trait.mean:.3f}" - try: - trait_dict['lod_score'] = f"{float(this_trait.LRS_score_repr) / 4.61:.1f}" - except: - trait_dict['lod_score'] = "N/A" - trait_dict['lrs_location'] = this_trait.LRS_location_repr - trait_dict['additive'] = "N/A" - if this_trait.additive != "": - trait_dict['additive'] = f"{this_trait.additive:.3f}" - # Convert any bytes in dict to a normal utf-8 string - for key in trait_dict.keys(): - if isinstance(trait_dict[key], bytes): - trait_dict[key] = trait_dict[key].decode('utf-8') - trait_list.append(trait_dict) + trait_dict['description'] = pre_pub_description - self.trait_list = trait_list + if result[6].isdigit(): + trait_dict['pubmed_text'] = result[6] - if self.dataset.type == "ProbeSet": - self.header_data_names = ['index', 'display_name', 'symbol', 'description', 'location', 'mean', 'lrs_score', 'lrs_location', 'additive'] - elif self.dataset.type == "Publish": - self.header_data_names = ['index', 'display_name', 'description', 'mean', 'authors', 'pubmed_text', 'lrs_score', 'lrs_location', 'additive'] - elif self.dataset.type == "Geno": - self.header_data_names = ['index', 'display_name', 'location'] + trait_dict['authors'] = result[5] + + if result[4] != "" and result[4] != None: + trait_dict['mean'] = f"{result[4]:.3f}" + + try: + trait_dict['lod_score'] = f"{float(result[5]) / 4.61:.1f}" + except: + trait_dict['lod_score'] = "N/A" + + try: + trait_dict['lrs_location'] = f"Chr{result[9]}: {float(result[10]):.6f}" + except: + trait_dict['lrs_location'] = "N/A" + + if result[5] != "": + trait_dict['additive'] = f"{result[6]:.3f}" + + # Convert any bytes in dict to a normal utf-8 string + for key in trait_dict.keys(): + if isinstance(trait_dict[key], bytes): + trait_dict[key] = trait_dict[key].decode('utf-8') + trait_list.append(trait_dict) + + self.trait_list = trait_list def search(self): """ @@ -179,13 +217,11 @@ class SearchResultPage(object): """ self.search_terms = parser.parse(self.search_terms) - logger.debug("After parsing:", self.search_terms) combined_from_clause = "" combined_where_clause = "" previous_from_clauses = [] #The same table can't be referenced twice in the from clause - logger.debug("len(search_terms)>1") symbol_list = [] if self.dataset.type == "ProbeSet": for a_search in self.search_terms: -- cgit v1.2.3 From 74a6e3f3d21edb9204b8e6e1188b04424c2f7446 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 25 Feb 2021 19:37:55 +0000 Subject: Phenotype regular search now runs without trait creation --- wqflask/wqflask/do_search.py | 23 +++++++++++++++++++---- wqflask/wqflask/search_results.py | 29 ++++++++++++++--------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 00636563..1478d2b6 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -189,10 +189,25 @@ class PhenotypeSearch(DoSearch): DoSearch.search_types['Publish'] = "PhenotypeSearch" base_query = """SELECT PublishXRef.Id, - PublishFreeze.createtime as thistable, - Publication.PubMed_ID as Publication_PubMed_ID, - Phenotype.Post_publication_description as Phenotype_Name - FROM Phenotype, PublishFreeze, Publication, PublishXRef """ + CAST(Phenotype.`Pre_publication_description` AS BINARY), + CAST(Phenotype.`Post_publication_description` AS BINARY), + Publication.`Authors`, + Publication.`Year`, + Publication.`PubMed_ID`, + PublishXRef.`mean`, + PublishXRef.`LRS`, + PublishXRef.`additive`, + PublishXRef.`Locus`, + InbredSet.`InbredSetCode`, + Geno.`Chr`, + Geno.`Mb` + FROM Species + INNER JOIN InbredSet ON InbredSet.`SpeciesId` = Species.`Id` + INNER JOIN PublishXRef ON PublishXRef.`InbredSetId` = InbredSet.`Id` + INNER JOIN PublishFreeze ON PublishFreeze.`InbredSetId` = InbredSet.`Id` + INNER JOIN Publication ON Publication.`Id` = PublishXRef.`PublicationId` + INNER JOIN Phenotype ON Phenotype.`Id` = PublishXRef.`PhenotypeId` + LEFT JOIN Geno ON PublishXRef.Locus = Geno.Name AND Geno.SpeciesId = Species.Id """ search_fields = ('Phenotype.Post_publication_description', 'Phenotype.Pre_publication_description', diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 8edf6147..b8e9f5de 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -124,8 +124,8 @@ class SearchResultPage(object): trait_dict['display_name'] = result[0] if self.dataset.type == "Publish": - if self.dataset.group_code: - trait_dict['display_name'] = self.dataset.group_code + "_" + result[0] + if self.dataset.group.code: + trait_dict['display_name'] = self.dataset.group.code + "_" + str(result[0]) trait_dict['dataset'] = self.dataset.name trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(trait_dict['name'], trait_dict['dataset'])) @@ -173,35 +173,34 @@ class SearchResultPage(object): trait_dict['pubmed_text'] = "N/A" trait_dict['mean'] = "N/A" trait_dict['additive'] = "N/A" - pre_pub_description = result[2].strip() - post_pub_description = result[3].strip() - if result[1] != "NULL" and result[1] != None: - trait_dict['pubmed_id'] = result[1] + pre_pub_description = "N/A" if result[1] is None else result[1].strip() + post_pub_description = "N/A" if result[2] is None else result[2].strip() + if result[5] != "NULL" and result[5] != None: + trait_dict['pubmed_id'] = result[5] trait_dict['pubmed_link'] = PUBMEDLINK_URL % trait_dict['pubmed_id'] trait_dict['description'] = post_pub_description else: trait_dict['description'] = pre_pub_description - if result[6].isdigit(): - trait_dict['pubmed_text'] = result[6] + if result[4].isdigit(): + trait_dict['pubmed_text'] = result[4] - trait_dict['authors'] = result[5] + trait_dict['authors'] = result[3] - if result[4] != "" and result[4] != None: - trait_dict['mean'] = f"{result[4]:.3f}" + if result[6] != "" and result[6] != None: + trait_dict['mean'] = f"{result[6]:.3f}" try: - trait_dict['lod_score'] = f"{float(result[5]) / 4.61:.1f}" + trait_dict['lod_score'] = f"{float(result[7]) / 4.61:.1f}" except: trait_dict['lod_score'] = "N/A" try: - trait_dict['lrs_location'] = f"Chr{result[9]}: {float(result[10]):.6f}" + trait_dict['lrs_location'] = f"Chr{result[11]}: {float(result[12]):.6f}" except: trait_dict['lrs_location'] = "N/A" - if result[5] != "": - trait_dict['additive'] = f"{result[6]:.3f}" + trait_dict['additive'] = "N/A" if not result[8] else f"{result[8]:.3f}" # Convert any bytes in dict to a normal utf-8 string for key in trait_dict.keys(): -- cgit v1.2.3 From 818897630e0bd2e97de9bbc3fca805eed64fd44f Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 25 Feb 2021 20:26:07 +0000 Subject: mRNA Assay searches without trait creation should work now --- wqflask/wqflask/do_search.py | 35 +++++++++++++++++++++++++---------- wqflask/wqflask/search_results.py | 39 +++++++++++---------------------------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 1478d2b6..4448e81e 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -78,16 +78,31 @@ class MrnaAssaySearch(DoSearch): DoSearch.search_types['ProbeSet'] = "MrnaAssaySearch" - base_query = """SELECT distinct ProbeSet.Name as TNAME, - 0 as thistable, - ProbeSetXRef.Mean as TMEAN, - ProbeSetXRef.LRS as TLRS, - ProbeSetXRef.PVALUE as TPVALUE, - ProbeSet.Chr_num as TCHR_NUM, - ProbeSet.Mb as TMB, - ProbeSet.Symbol as TSYMBOL, - ProbeSet.name_num as TNAME_NUM - FROM ProbeSetXRef, ProbeSet """ + base_query = """ + SELECT + ProbeSetFreeze.`Name`, + ProbeSetFreeze.`FullName`, + ProbeSet.`Name`, + ProbeSet.`Symbol`, + CAST(ProbeSet.`description` AS BINARY), + CAST(ProbeSet.`Probe_Target_Description` AS BINARY), + ProbeSet.`Chr`, + ProbeSet.`Mb`, + ProbeSetXRef.`Mean`, + ProbeSetXRef.`LRS`, + ProbeSetXRef.`Locus`, + ProbeSetXRef.`pValue`, + ProbeSetXRef.`additive`, + Geno.`Chr` as geno_chr, + Geno.`Mb` as geno_mb + FROM Species + INNER JOIN InbredSet ON InbredSet.`SpeciesId`= Species.`Id` + INNER JOIN ProbeFreeze ON ProbeFreeze.`InbredSetId` = InbredSet.`Id` + INNER JOIN Tissue ON ProbeFreeze.`TissueId` = Tissue.`Id` + INNER JOIN ProbeSetFreeze ON ProbeSetFreeze.`ProbeFreezeId` = ProbeFreeze.`Id` + INNER JOIN ProbeSetXRef ON ProbeSetXRef.`ProbeSetFreezeId` = ProbeSetFreeze.`Id` + INNER JOIN ProbeSet ON ProbeSet.`Id` = ProbeSetXRef.`ProbeSetId` + LEFT JOIN Geno ON ProbeSetXRef.`Locus` = Geno.`Name` AND Geno.`SpeciesId` = Species.`Id` """ header_fields = ['Index', 'Record', diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index b8e9f5de..97cc6581 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -130,38 +130,21 @@ class SearchResultPage(object): trait_dict['dataset'] = self.dataset.name trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(trait_dict['name'], trait_dict['dataset'])) if self.dataset.type == "ProbeSet": - trait_dict['symbol'] = "N/A" - if result[10]: - trait_dict['symbol'] = result[10] - trait_dict['description'] = "N/A" - description_string = result[2] - if str(description_string) != "" and description_string != None: - description_display = description_string - else: - description_display = trait_dict['symbol'] + trait_dict['symbol'] = "N/A" if result[3] is None else result[3].strip() + description_text = "N/A" if result[4] is None or str(result[4]) == "" else trait_dict['symbol'] - target_string = result[3] - if str(target_string) != "" and target_string != None: - description_display = description_display + "; " + target_string.strip() + target_string = result[5] + description_display = description_text if target_string is None or str(target_string) == "" else description_text + "; " + str(target_string).strip() trait_dict['description'] = description_display trait_dict['location'] = "N/A" - if (result[8] != "NULL" and result[8] != "") and (result[9] != 0): - trait_dict['location'] = f"Chr{result[8]}: {float(result[9]):.6f}" - trait_dict['mean'] = "N/A" - trait_dict['additive'] = "N/A" - if result[4] != "" and result[4] != None: - trait_dict['mean'] = f"{result[4]:.3f}" - try: - trait_dict['lod_score'] = f"{float(result[5]) / 4.61:.1f}" - except: - trait_dict['lod_score'] = "N/A" - try: - trait_dict['lrs_location'] = f"Chr{result[12]}: {float(result[13]):.6f}" - except: - trait_dict['lrs_location'] = "N/A" - if result[5] != "": - trait_dict['additive'] = f"{result[7]:.3f}" + if (result[6] is not None) and (result[6] != "") and (result[7] is not None) and (result[7] != 0): + trait_dict['location'] = f"Chr{result[6]}: {float(result[7]):.6f}" + + trait_dict['mean'] = "N/A" if result[8] is None or result[8] == "" else f"{result[8]:.3f}" + trait_dict['additive'] = "N/A" if result[12] is None or result[12] == "" else f"{result[12]:.3f}" + trait_dict['lod_score'] = "N/A" if result[9] is None or result[9] == "" else f"{float(result[9]) / 4.61:.1f}" + trait_dict['lrs_location'] = "N/A" if result[13] is None or result[13] == "" or result[14] is None else f"Chr{result[13]}: {float(result[14]):.6f}" elif self.dataset.type == "Geno": trait_dict['location'] = "N/A" if (result[4] != "NULL" and result[4] != "") and (result[5] != 0): -- cgit v1.2.3 From bd421438f1f0b4de913fa40cd49cfcda27e6b16f Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 2 Mar 2021 22:47:16 +0000 Subject: Changed formatting RifSearch clauses and also changes from clause to an INNER JOIN --- wqflask/wqflask/do_search.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 4448e81e..f3ef68b2 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -403,12 +403,10 @@ class RifSearch(MrnaAssaySearch): DoSearch.search_types['ProbeSet_RIF'] = "RifSearch" def get_from_clause(self): - return ", GeneRIF_BASIC " + return f" INNER JOIN GeneRIF_BASIC ON GeneRIF_BASIC.`symbol` = { self.dataset.type }.`symbol` " def get_where_clause(self): - where_clause = """( %s.symbol = GeneRIF_BASIC.symbol and - MATCH (GeneRIF_BASIC.comment) - AGAINST ('+%s' IN BOOLEAN MODE)) """ % (self.dataset.type, self.search_term[0]) + where_clause = f"(MATCH (GeneRIF_BASIC.comment) AGAINST ('+{ self.search_term[0] }' IN BOOLEAN MODE)) " return where_clause -- cgit v1.2.3 From bc1b297acdd85f9bc04cd402f646ce123401b907 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 18 Oct 2021 17:55:09 +0000 Subject: Replace this_trait.dataset.type with just self.dataset.type --- wqflask/wqflask/search_results.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index bc0c08a1..5db469c1 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -200,13 +200,14 @@ class SearchResultPage: self.max_widths[key] = max(len(str(trait[key])), self.max_widths[key]) if key in self.max_widths else len(str(trait[key])) self.wide_columns_exist = False - if this_trait.dataset.type == "Publish": + if self.dataset.type == "Publish": if (self.max_widths['display_name'] > 25 or self.max_widths['description'] > 100 or self.max_widths['authors']> 80): self.wide_columns_exist = True - if this_trait.dataset.type == "ProbeSet": + if self.dataset.type == "ProbeSet": if (self.max_widths['display_name'] > 25 or self.max_widths['symbol'] > 25 or self.max_widths['description'] > 100): self.wide_columns_exist = True + self.trait_list = trait_list def search(self): -- cgit v1.2.3 From 789f91513a551dfe65133a2ae6191e6d98cbfcf2 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 18 Oct 2021 18:29:52 +0000 Subject: Changed table width to 100% for non-Geno datasets, since it can always be manually resized --- wqflask/wqflask/templates/search_result_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 72a4b560..5922ac75 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -126,7 +126,7 @@ {% endif %} {% endif %} -
+
-- cgit v1.2.3 From 7f241d1205eefe5bec871ef2d5b99168e0e136d7 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 18 Oct 2021 18:30:55 +0000 Subject: Fixed the way group code was used when setting phenotype trait display name + prevent encoding error with try/except --- wqflask/wqflask/search_results.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 5db469c1..61970e7e 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -122,8 +122,8 @@ class SearchResultPage: trait_dict['display_name'] = result[0] if self.dataset.type == "Publish": - if self.dataset.group.code: - trait_dict['display_name'] = self.dataset.group.code + "_" + str(result[0]) + if result[10]: + trait_dict['display_name'] = str(result[10]) + "_" + str(result[0]) trait_dict['dataset'] = self.dataset.name trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(trait_dict['name'], trait_dict['dataset'])) @@ -186,7 +186,11 @@ class SearchResultPage: # Convert any bytes in dict to a normal utf-8 string for key in trait_dict.keys(): if isinstance(trait_dict[key], bytes): - trait_dict[key] = trait_dict[key].decode('utf-8') + try: + trait_dict[key] = trait_dict[key].decode('utf-8') + except UnicodeDecodeError: + trait_dict[key] = trait_dict[key].decode('latin-1') + trait_list.append(trait_dict) if self.results: -- cgit v1.2.3

Loading...