humann/store.py
def convert_alignments_to_gene_scores(self,gene_scores_store):
        """
        Computes the scores for all genes per bug
        Add to the gene_scores store
        """
        
        # calculate the score per bug and gene
        # for a single query result, it is 1/a.length
        # if a query matches multiple bugs and genes, its score is distributed by weighted average
        # scores from multiple queries are added up per bug and gene
        # see unit tests for examples
        result={}
        resultAll={}
        for bug, gene, score in self.query('''
              select bug, reference, sum(normalized_score_partial) as score from (
                  select
                    a.query,
                    a.bug,
                    a.reference,
                    sum(a.score / a.length ) / (total_score_for_query) as normalized_score_partial
                  from
                  alignment a join (
                    select query, sum(score) as total_score_for_query
                    from alignment group by query
                    ) as m
                  where a.query = m.query
                  group by a.bug, a.reference, a.query
               ) group by bug, reference
               order by bug, reference
            '''):
            if bug not in result:
                result[bug]={}
            result[bug][gene]=score
            if gene not in resultAll:
                resultAll[gene]=0
            resultAll[gene]+=score

        # Add to the store
        for bug in result:
            gene_scores_store.add(result[bug], bug)
        gene_scores_store.add(resultAll, "all")

        # Log a summary, and print if in verbose mode
        message="\n".join(["{0} : {1} gene families".format(bug, len(result[bug])) for bug in result])
        message="Total gene families  : " +str(sum([len(result[bug]) for bug in result]))+"\n"+message
        if config.verbose:
            print(message)
        logger.info("\n"+message)

        Computes the scores for all genes per bug
        Add to the gene_scores store
        
Computes the scores for all genes per bug
Add to the gene_scores store
Computes the scores for all genes per bug Add to the gene_scores store
def convert_alignments_to_gene_scores(self,gene_scores_store):
        result={}
        resultAll={}
        for bug, gene, score in self.query('''
              select bug, reference, sum(normalized_score_partial) as score from (
                  select
                    a.query,
                    a.bug,
                    a.reference,
                    sum(a.score / a.length ) / (total_score_for_query) as normalized_score_partial
                  from
                  alignment a join (
                    select query, sum(score) as total_score_for_query
                    from alignment group by query
                    ) as m
                  where a.query = m.query
                  group by a.bug, a.reference, a.query
               ) group by bug, reference
               order by bug, reference
            '''):
            if bug not in result:
                result[bug]={}
            result[bug][gene]=score
            if gene not in resultAll:
                resultAll[gene]=0
            resultAll[gene]+=score
        for bug in result:
            gene_scores_store.add(result[bug], bug)
        gene_scores_store.add(resultAll, "all")
        message="\n".join(["{0} : {1} gene families".format(bug, len(result[bug])) for bug in result])
        message="Total gene families  : " +str(sum([len(result[bug]) for bug in result]))+"\n"+message
        if config.verbose:
            print(message)
        logger.info("\n"+message)
def convert_alignments_to_gene_scores ( self , gene_scores_store ) : result = { } resultAll = { } for bug , gene , score in self . query ( '''
              select bug, reference, sum(normalized_score_partial) as score from (
                  select
                    a.query,
                    a.bug,
                    a.reference,
                    sum(a.score / a.length ) / (total_score_for_query) as normalized_score_partial
                  from
                  alignment a join (
                    select query, sum(score) as total_score_for_query
                    from alignment group by query
                    ) as m
                  where a.query = m.query
                  group by a.bug, a.reference, a.query
               ) group by bug, reference
               order by bug, reference
            ''' ) : if bug not in result : result [ bug ] = { } result [ bug ] [ gene ] = score if gene not in resultAll : resultAll [ gene ] = 0 resultAll [ gene ] += score for bug in result : gene_scores_store . add ( result [ bug ] , bug ) gene_scores_store . add ( resultAll , "all" ) message = "\n" . join ( [ "{0} : {1} gene families" . format ( bug , len ( result [ bug ] ) ) for bug in result ] ) message = "Total gene families  : " + str ( sum ( [ len ( result [ bug ] ) for bug in result ] ) ) + "\n" + message if config . verbose : print ( message ) logger . info ( "\n" + message )
Computes the scores for all genes per bug
Add to the gene_scores store
Computes the scores for all genes per bug Add to the gene_scores store
"""
        Computes the scores for all genes per bug
        Add to the gene_scores store
        """ # calculate the score per bug and gene # for a single query result, it is 1/a.length # if a query matches multiple bugs and genes, its score is distributed by weighted average # scores from multiple queries are added up per bug and gene # see unit tests for examples # Add to the store # Log a summary, and print if in verbose mode
self
gene_scores_store