humann/quantify/modules.py
def print_pathways(pathways, file, header, pathway_names, sorted_pathways_and_bugs,
                   unmapped_all, unintegrated_all, unintegrated_per_bug):
    """
    Print the pathways data to a file organized by pathway
    """
    
    logger.debug("Print pathways %s", header)
    
    delimiter=config.output_file_column_delimiter
    category_delimiter=config.output_file_category_delimiter            
 
    # Create the header
    column_name=config.file_basename + header
    if config.remove_column_description_output:
        column_name=config.file_basename
    tsv_output=["# Pathway"+ delimiter + column_name]
    
    # Add the unmapped and unintegrated values
    tsv_output.append(config.unmapped_pathway_name+delimiter+utilities.format_float_to_string(unmapped_all))
    tsv_output.append(config.unintegrated_pathway_name+delimiter+utilities.format_float_to_string(unintegrated_all))
    # Process and print per bug if selected
    if not config.remove_stratified_output:
        for bug in utilities.double_sort(unintegrated_per_bug):
            tsv_output.append(config.unintegrated_pathway_name+category_delimiter+bug
                              +delimiter+utilities.format_float_to_string(unintegrated_per_bug[bug]))
            
    # Print out all pathways sorted
    for pathway, bugs_list in sorted_pathways_and_bugs:
        all_score=pathways.get_score(pathway)
        pathway_name=pathway_names.get_name(pathway)
        # Print the computation of all bugs for pathway
        tsv_output.append(pathway_name+delimiter+utilities.format_float_to_string(all_score))
        # Process and print per bug if selected
        if not config.remove_stratified_output:
            # Print scores for all bugs sorted
            for bug in bugs_list:
                score=pathways.get_score_for_bug(bug,pathway)
                tsv_output.append(pathway_name+category_delimiter+bug+delimiter
                                  +utilities.format_float_to_string(score))
 
    if config.output_format == "biom":
        # Open a temp file if a conversion to biom is selected
        tmpfile=utilities.unnamed_temp_file()
        file_out=open(tmpfile,"w")
        file_out.write("\n".join(tsv_output))
        file_out.close()
        
        utilities.tsv_to_biom(tmpfile,file,"Pathway")
            
    else:
        # Write the final file as tsv
        file_handle=open(file,"w") 
        file_handle.write("\n".join(tsv_output))                  
        file_handle.close()

    Print the pathways data to a file organized by pathway
    
Print the pathways data to a file organized by pathway
Print the pathways data to a file organized by pathway
def print_pathways(pathways, file, header, pathway_names, sorted_pathways_and_bugs,
                   unmapped_all, unintegrated_all, unintegrated_per_bug):
    logger.debug("Print pathways %s", header)
    delimiter=config.output_file_column_delimiter
    category_delimiter=config.output_file_category_delimiter            
    column_name=config.file_basename + header
    if config.remove_column_description_output:
        column_name=config.file_basename
    tsv_output=["# Pathway"+ delimiter + column_name]
    tsv_output.append(config.unmapped_pathway_name+delimiter+utilities.format_float_to_string(unmapped_all))
    tsv_output.append(config.unintegrated_pathway_name+delimiter+utilities.format_float_to_string(unintegrated_all))
    if not config.remove_stratified_output:
        for bug in utilities.double_sort(unintegrated_per_bug):
            tsv_output.append(config.unintegrated_pathway_name+category_delimiter+bug
                              +delimiter+utilities.format_float_to_string(unintegrated_per_bug[bug]))
    for pathway, bugs_list in sorted_pathways_and_bugs:
        all_score=pathways.get_score(pathway)
        pathway_name=pathway_names.get_name(pathway)
        tsv_output.append(pathway_name+delimiter+utilities.format_float_to_string(all_score))
        if not config.remove_stratified_output:
            for bug in bugs_list:
                score=pathways.get_score_for_bug(bug,pathway)
                tsv_output.append(pathway_name+category_delimiter+bug+delimiter
                                  +utilities.format_float_to_string(score))
    if config.output_format == "biom":
        tmpfile=utilities.unnamed_temp_file()
        file_out=open(tmpfile,"w")
        file_out.write("\n".join(tsv_output))
        file_out.close()
        utilities.tsv_to_biom(tmpfile,file,"Pathway")
    else:
        file_handle=open(file,"w") 
        file_handle.write("\n".join(tsv_output))                  
        file_handle.close()
def print_pathways ( pathways , file , header , pathway_names , sorted_pathways_and_bugs , unmapped_all , unintegrated_all , unintegrated_per_bug ) : logger . debug ( "Print pathways %s" , header ) delimiter = config . output_file_column_delimiter category_delimiter = config . output_file_category_delimiter column_name = config . file_basename + header if config . remove_column_description_output : column_name = config . file_basename tsv_output = [ "# Pathway" + delimiter + column_name ] tsv_output . append ( config . unmapped_pathway_name + delimiter + utilities . format_float_to_string ( unmapped_all ) ) tsv_output . append ( config . unintegrated_pathway_name + delimiter + utilities . format_float_to_string ( unintegrated_all ) ) if not config . remove_stratified_output : for bug in utilities . double_sort ( unintegrated_per_bug ) : tsv_output . append ( config . unintegrated_pathway_name + category_delimiter + bug + delimiter + utilities . format_float_to_string ( unintegrated_per_bug [ bug ] ) ) for pathway , bugs_list in sorted_pathways_and_bugs : all_score = pathways . get_score ( pathway ) pathway_name = pathway_names . get_name ( pathway ) tsv_output . append ( pathway_name + delimiter + utilities . format_float_to_string ( all_score ) ) if not config . remove_stratified_output : for bug in bugs_list : score = pathways . get_score_for_bug ( bug , pathway ) tsv_output . append ( pathway_name + category_delimiter + bug + delimiter + utilities . format_float_to_string ( score ) ) if config . output_format == "biom" : tmpfile = utilities . unnamed_temp_file ( ) file_out = open ( tmpfile , "w" ) file_out . write ( "\n" . join ( tsv_output ) ) file_out . close ( ) utilities . tsv_to_biom ( tmpfile , file , "Pathway" ) else : file_handle = open ( file , "w" ) file_handle . write ( "\n" . join ( tsv_output ) ) file_handle . close ( )
Print the pathways data to a file organized by pathway
Print the pathways data to a file organized by pathway
"""
    Print the pathways data to a file organized by pathway
    """ # Create the header # Add the unmapped and unintegrated values # Process and print per bug if selected # Print out all pathways sorted # Print the computation of all bugs for pathway # Process and print per bug if selected # Print scores for all bugs sorted # Open a temp file if a conversion to biom is selected # Write the final file as tsv
pathways
file
header
pathway_names
sorted_pathways_and_bugs
unmapped_all
unintegrated_all
unintegrated_per_bug