humann/quantify/modules.py
def compute_gene_abundance_in_pathways(gene_scores, reactions_database, reactions_in_pathways_present):
    """
    Compute the abundance of genes present in pathways found
    Also compute the remaining gene abundance that did not contribute to any pathways present
    """
    
    # From each of the reactions present in pathways, find the list of all genes
    # that contributed to the pathway abundance (for each bug found in community)
    genes_in_pathways_present={}
    for bug in reactions_in_pathways_present:
        genes_in_pathways_present[bug]=set()
        for reaction in reactions_in_pathways_present[bug]:
            if reactions_database:
                # Find the list of genes for this reaction
                gene_list=reactions_database.find_genes(reaction)
                genes_in_pathways_present[bug].update(gene_list)
            else:
                # If the reactions database is not provided, then the pathway is defined
                # in terms of genes
                genes_in_pathways_present[bug].add(reaction)
        
    # Compute the abundance for the genes present
    gene_abundance_in_pathways={}
    remaining_gene_abundance={}
    for bug in genes_in_pathways_present:
        for gene in genes_in_pathways_present[bug]:
            gene_abundance_in_pathways[bug]=gene_abundance_in_pathways.get(bug,0)+gene_scores.get_score(bug,gene)
            
        # Compute the remaining gene abundance
        total_gene_abundance=sum(gene_scores.scores_for_bug(bug).values())
        remaining_gene_abundance[bug]=total_gene_abundance-gene_abundance_in_pathways.get(bug,0)
        
    return gene_abundance_in_pathways, remaining_gene_abundance

    Compute the abundance of genes present in pathways found
    Also compute the remaining gene abundance that did not contribute to any pathways present
    
Compute the abundance of genes present in pathways found
Also compute the remaining gene abundance that did not contribute to any pathways present
Compute the abundance of genes present in pathways found Also compute the remaining gene abundance that did not contribute to any pathways present
def compute_gene_abundance_in_pathways(gene_scores, reactions_database, reactions_in_pathways_present):
    genes_in_pathways_present={}
    for bug in reactions_in_pathways_present:
        genes_in_pathways_present[bug]=set()
        for reaction in reactions_in_pathways_present[bug]:
            if reactions_database:
                gene_list=reactions_database.find_genes(reaction)
                genes_in_pathways_present[bug].update(gene_list)
            else:
                genes_in_pathways_present[bug].add(reaction)
    gene_abundance_in_pathways={}
    remaining_gene_abundance={}
    for bug in genes_in_pathways_present:
        for gene in genes_in_pathways_present[bug]:
            gene_abundance_in_pathways[bug]=gene_abundance_in_pathways.get(bug,0)+gene_scores.get_score(bug,gene)
        total_gene_abundance=sum(gene_scores.scores_for_bug(bug).values())
        remaining_gene_abundance[bug]=total_gene_abundance-gene_abundance_in_pathways.get(bug,0)
    return gene_abundance_in_pathways, remaining_gene_abundance
def compute_gene_abundance_in_pathways ( gene_scores , reactions_database , reactions_in_pathways_present ) : genes_in_pathways_present = { } for bug in reactions_in_pathways_present : genes_in_pathways_present [ bug ] = set ( ) for reaction in reactions_in_pathways_present [ bug ] : if reactions_database : gene_list = reactions_database . find_genes ( reaction ) genes_in_pathways_present [ bug ] . update ( gene_list ) else : genes_in_pathways_present [ bug ] . add ( reaction ) gene_abundance_in_pathways = { } remaining_gene_abundance = { } for bug in genes_in_pathways_present : for gene in genes_in_pathways_present [ bug ] : gene_abundance_in_pathways [ bug ] = gene_abundance_in_pathways . get ( bug , 0 ) + gene_scores . get_score ( bug , gene ) total_gene_abundance = sum ( gene_scores . scores_for_bug ( bug ) . values ( ) ) remaining_gene_abundance [ bug ] = total_gene_abundance - gene_abundance_in_pathways . get ( bug , 0 ) return gene_abundance_in_pathways , remaining_gene_abundance
Compute the abundance of genes present in pathways found
Also compute the remaining gene abundance that did not contribute to any pathways present
Compute the abundance of genes present in pathways found Also compute the remaining gene abundance that did not contribute to any pathways present
"""
    Compute the abundance of genes present in pathways found
    Also compute the remaining gene abundance that did not contribute to any pathways present
    """ # From each of the reactions present in pathways, find the list of all genes # that contributed to the pathway abundance (for each bug found in community) # Find the list of genes for this reaction # If the reactions database is not provided, then the pathway is defined # in terms of genes # Compute the abundance for the genes present # Compute the remaining gene abundance
gene_scores
reactions_database
reactions_in_pathways_present