def gen_search_result(self): """ Get the info displayed in the search result table from the set of results computed in the "search" function """ self.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)) for index, result in enumerate(self.results): if not result: continue #### Excel file needs to be generated #### #logger.debug("foo locals are:", locals()) trait_id = result[0] this_trait = trait.GeneralTrait(dataset=self.dataset, name=trait_id, get_qtl_info=True, get_sample_info=False) self.trait_list.append(this_trait) json_trait_list.append(trait.jsonable_table_row(this_trait, self.dataset.name, index + 1)) self.json_trait_list = json.dumps(json_trait_list)
def gen_search_result(self): """ Get the info displayed in the search result table from the set of results computed in the "search" function """ self.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)) for index, result in enumerate(self.results): if not result: continue #### Excel file needs to be generated #### #logger.debug("foo locals are:", locals()) trait_id = result[0] this_trait = trait.GeneralTrait(dataset=self.dataset, name=trait_id, get_qtl_info=True, get_sample_info=False) self.trait_list.append(this_trait) json_trait_list.append( trait.jsonable_table_row(this_trait, self.dataset.name, index + 1)) self.json_trait_list = json.dumps(json_trait_list)
def __init__(self, dataset, name=None): """This sets self.group and self.group_id""" #logger.debug("DATASET NAME2:", dataset.name) if name == None: self.name, self.id, self.genetic_type = fetchone( dataset.query_for_group) else: self.name, self.id, self.genetic_type = fetchone( "SELECT InbredSet.Name, InbredSet.Id, InbredSet.GeneticType FROM InbredSet where Name='%s'" % name) if self.name == 'BXD300': self.name = "BXD" self.f1list = None self.parlist = None self.get_f1_parent_strains() self.accession_id = self.get_accession_id() self.mapping_id, self.mapping_names = self.get_mapping_methods() self.species = webqtlDatabaseFunction.retrieve_species(self.name) self.incparentsf1 = False self.allsamples = None self._datasets = None self.genofile = None
def __init__(self, dataset): """This sets self.group and self.group_id""" #logger.debug("DATASET NAME2:", dataset.name) self.name, self.id = fetchone(dataset.query_for_group) if self.name == 'BXD300': self.name = "BXD" self.f1list = None self.parlist = None self.get_f1_parent_strains() #logger.debug("parents/f1s: {}:{}".format(self.parlist, self.f1list)) self.species = webqtlDatabaseFunction.retrieve_species(self.name) self.incparentsf1 = False self.allsamples = None self._datasets = None
def __init__(self, dataset, name=None): """This sets self.group and self.group_id""" #logger.debug("DATASET NAME2:", dataset.name) if name == None: self.name, self.id, self.genetic_type = fetchone(dataset.query_for_group) else: self.name, self.id, self.genetic_type = fetchone("SELECT InbredSet.Name, InbredSet.Id, InbredSet.GeneticType FROM InbredSet where Name='%s'" % name) if self.name == 'BXD300': self.name = "BXD" self.f1list = None self.parlist = None self.get_f1_parent_strains() self.accession_id = self.get_accession_id() self.mapping_id, self.mapping_names = self.get_mapping_methods() self.species = webqtlDatabaseFunction.retrieve_species(self.name) self.incparentsf1 = False self.allsamples = None self._datasets = None self.genofile = None
def gen_search_result(self): """ Get the info displayed in the search result table from the set of results computed in the "search" function """ 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)) for index, result in enumerate(self.results): if not result: continue #### Excel file needs to be generated #### trait_dict = {} trait_id = result[0] trait_dict['index'] = index + 1 this_trait = trait.GeneralTrait(dataset=self.dataset, name=trait_id, get_qtl_info=True, get_sample_info=False) trait_dict['name'] = this_trait.name if this_trait.dataset.type == "Publish": trait_dict['display_name'] = this_trait.display_name 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'] = this_trait.description_display.decode( 'utf-8', 'replace') 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'] = '%.3f' % this_trait.mean trait_dict['lrs_score'] = this_trait.LRS_score_repr trait_dict['lrs_location'] = this_trait.LRS_location_repr if this_trait.additive != "": trait_dict['additive'] = '%.3f' % this_trait.additive elif this_trait.dataset.type == "Geno": trait_dict['location'] = this_trait.location_repr elif this_trait.dataset.type == "Publish": 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'] = '%.3f' % this_trait.mean trait_dict['lrs_score'] = this_trait.LRS_score_repr trait_dict['lrs_location'] = this_trait.LRS_location_repr trait_dict['additive'] = "N/A" if this_trait.additive != "": trait_dict['additive'] = '%.3f' % this_trait.additive trait_list.append(trait_dict) #json_trait_list.append(trait.jsonable_table_row(this_trait, self.dataset.name, index + 1)) self.trait_list = json.dumps(trait_list)
def gen_search_result(self): """ Get the info displayed in the search result table from the set of results computed in the "search" function """ 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)) 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 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) self.trait_list = trait_list 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']