humann/store.py
def add_from_file(self,file,id_mapping_file=None):
        """
        Add all of the gene scores from the file
        Use id mapping if provided
        """
        
        # Process the id mapping file if present
        id_mapping={}
        if id_mapping_file:
            id_mapping=store_id_mapping(id_mapping_file)
            
        unaligned_reads_count=0
        
        # Check the file exists and is readable
        utilities.file_exists_readable(file)
         
        file_handle=open(file,"rt")
         
        line=file_handle.readline()
        while line:
            # Ignore comment lines
            if not re.search(config.gene_table_comment_indicator,line):
                data=line.rstrip().split(config.gene_table_delimiter)
                gene=""
                bug="all"
                
                # Use id mapping if present
                if id_mapping:
                    if data[config.gene_table_gene_index] in id_mapping:
                         [gene,length,bug]=id_mapping[data[config.gene_table_gene_index]]
                
                # If gene not set with id mapping, then process
                if not gene:
                    if config.gene_table_category_delimiter in data[config.gene_table_gene_index]:
                        gene_data=data[config.gene_table_gene_index].split(
                            config.gene_table_category_delimiter)
                        gene=gene_data[0]
                        bug=gene_data[1]
                    else:
                        gene=data[config.gene_table_gene_index]
                    
                # remove the name of the gene if present
                if gene:
                    gene=gene.split(config.name_mapping_join)[0]
                    
                try:
                    value=float(data[config.gene_table_value_index])
                except (ValueError, IndexError):
                    value=0
                    if line.rstrip():
                        logger.debug("Unable to convert gene table value to float: %s",
                            line.rstrip())
                if gene == config.unmapped_gene_name:
                    unaligned_reads_count = value
                else:
                    self.add_single_score(bug,gene,value)
            line=file_handle.readline()

        file_handle.close()
        
        return unaligned_reads_count

        Add all of the gene scores from the file
        Use id mapping if provided
        
Add all of the gene scores from the file
Use id mapping if provided
Add all of the gene scores from the file Use id mapping if provided
def add_from_file(self,file,id_mapping_file=None):
        id_mapping={}
        if id_mapping_file:
            id_mapping=store_id_mapping(id_mapping_file)
        unaligned_reads_count=0
        utilities.file_exists_readable(file)
        file_handle=open(file,"rt")
        line=file_handle.readline()
        while line:
            if not re.search(config.gene_table_comment_indicator,line):
                data=line.rstrip().split(config.gene_table_delimiter)
                gene=""
                bug="all"
                if id_mapping:
                    if data[config.gene_table_gene_index] in id_mapping:
                         [gene,length,bug]=id_mapping[data[config.gene_table_gene_index]]
                if not gene:
                    if config.gene_table_category_delimiter in data[config.gene_table_gene_index]:
                        gene_data=data[config.gene_table_gene_index].split(
                            config.gene_table_category_delimiter)
                        gene=gene_data[0]
                        bug=gene_data[1]
                    else:
                        gene=data[config.gene_table_gene_index]
                if gene:
                    gene=gene.split(config.name_mapping_join)[0]
                try:
                    value=float(data[config.gene_table_value_index])
                except (ValueError, IndexError):
                    value=0
                    if line.rstrip():
                        logger.debug("Unable to convert gene table value to float: %s",
                            line.rstrip())
                if gene == config.unmapped_gene_name:
                    unaligned_reads_count = value
                else:
                    self.add_single_score(bug,gene,value)
            line=file_handle.readline()
        file_handle.close()
        return unaligned_reads_count
def add_from_file ( self , file , id_mapping_file = None ) : id_mapping = { } if id_mapping_file : id_mapping = store_id_mapping ( id_mapping_file ) unaligned_reads_count = 0 utilities . file_exists_readable ( file ) file_handle = open ( file , "rt" ) line = file_handle . readline ( ) while line : if not re . search ( config . gene_table_comment_indicator , line ) : data = line . rstrip ( ) . split ( config . gene_table_delimiter ) gene = "" bug = "all" if id_mapping : if data [ config . gene_table_gene_index ] in id_mapping : [ gene , length , bug ] = id_mapping [ data [ config . gene_table_gene_index ] ] if not gene : if config . gene_table_category_delimiter in data [ config . gene_table_gene_index ] : gene_data = data [ config . gene_table_gene_index ] . split ( config . gene_table_category_delimiter ) gene = gene_data [ 0 ] bug = gene_data [ 1 ] else : gene = data [ config . gene_table_gene_index ] if gene : gene = gene . split ( config . name_mapping_join ) [ 0 ] try : value = float ( data [ config . gene_table_value_index ] ) except ( ValueError , IndexError ) : value = 0 if line . rstrip ( ) : logger . debug ( "Unable to convert gene table value to float: %s" , line . rstrip ( ) ) if gene == config . unmapped_gene_name : unaligned_reads_count = value else : self . add_single_score ( bug , gene , value ) line = file_handle . readline ( ) file_handle . close ( ) return unaligned_reads_count
Add all of the gene scores from the file
Use id mapping if provided
Add all of the gene scores from the file Use id mapping if provided
"""
        Add all of the gene scores from the file
        Use id mapping if provided
        """ # Process the id mapping file if present # Check the file exists and is readable # Ignore comment lines # Use id mapping if present # If gene not set with id mapping, then process # remove the name of the gene if present
self
file
id_mapping_file