humann/tools/merge_abundance.py
def read_gene_table(gene_table):
    """
    Read the input gene table
    Store the abundances related to each bug
    """
    
    gene_table_data={}
    gene_names={}
    
    lines=util.process_gene_table_with_header(gene_table, allow_for_missing_header=True)
    header=next(lines)
    
    for line in lines:
        # process if not a comment
        if not re.match("#",line):
            data=line.split(TABLE_DELIMITER)
            
            try:
                gene,bug=data[0].split(BUG_DELIMITER)
            except ValueError:
                gene=data[0]
                bug="all"
                
            try:
                # remove the gene name if present and store
                if GENE_NAME_DELIMITER in gene:
                    info=gene.split(GENE_NAME_DELIMITER)
                    gene = info[0]
                    gene_names[gene]=" ".join(info[1:])
                data_point=float(data[1])
            except (IndexError,ValueError):
                gene=""

            if gene and data_point > 0:
                # check for an EC set
                genes=[gene]
                if EC_DELIMITER in gene:
                    genes=gene.split(EC_DELIMITER)
                    
                for gene in genes:
                    if not gene in gene_table_data:
                        gene_table_data[gene]={}
                    gene_table_data[gene][bug]=gene_table_data[gene].get(bug,0)+data_point
        
    return gene_table_data, gene_names

    Read the input gene table
    Store the abundances related to each bug
    
Read the input gene table
Store the abundances related to each bug
Read the input gene table Store the abundances related to each bug
def read_gene_table(gene_table):
    gene_table_data={}
    gene_names={}
    lines=util.process_gene_table_with_header(gene_table, allow_for_missing_header=True)
    header=next(lines)
    for line in lines:
        if not re.match("#",line):
            data=line.split(TABLE_DELIMITER)
            try:
                gene,bug=data[0].split(BUG_DELIMITER)
            except ValueError:
                gene=data[0]
                bug="all"
            try:
                if GENE_NAME_DELIMITER in gene:
                    info=gene.split(GENE_NAME_DELIMITER)
                    gene = info[0]
                    gene_names[gene]=" ".join(info[1:])
                data_point=float(data[1])
            except (IndexError,ValueError):
                gene=""
            if gene and data_point > 0:
                genes=[gene]
                if EC_DELIMITER in gene:
                    genes=gene.split(EC_DELIMITER)
                for gene in genes:
                    if not gene in gene_table_data:
                        gene_table_data[gene]={}
                    gene_table_data[gene][bug]=gene_table_data[gene].get(bug,0)+data_point
    return gene_table_data, gene_names
def read_gene_table ( gene_table ) : gene_table_data = { } gene_names = { } lines = util . process_gene_table_with_header ( gene_table , allow_for_missing_header = True ) header = next ( lines ) for line in lines : if not re . match ( "#" , line ) : data = line . split ( TABLE_DELIMITER ) try : gene , bug = data [ 0 ] . split ( BUG_DELIMITER ) except ValueError : gene = data [ 0 ] bug = "all" try : if GENE_NAME_DELIMITER in gene : info = gene . split ( GENE_NAME_DELIMITER ) gene = info [ 0 ] gene_names [ gene ] = " " . join ( info [ 1 : ] ) data_point = float ( data [ 1 ] ) except ( IndexError , ValueError ) : gene = "" if gene and data_point > 0 : genes = [ gene ] if EC_DELIMITER in gene : genes = gene . split ( EC_DELIMITER ) for gene in genes : if not gene in gene_table_data : gene_table_data [ gene ] = { } gene_table_data [ gene ] [ bug ] = gene_table_data [ gene ] . get ( bug , 0 ) + data_point return gene_table_data , gene_names
Read the input gene table
Store the abundances related to each bug
Read the input gene table Store the abundances related to each bug
"""
    Read the input gene table
    Store the abundances related to each bug
    """ # process if not a comment # remove the gene name if present and store # check for an EC set
gene_table