def _write_consensus_strings(self, output):
logging.info("<STR_LIT>" % (output))<EOL>with open(output, '<STR_LIT:w>') as out:<EOL><INDENT>for tip in self.tree.leaf_nodes():<EOL><INDENT>tax_name = tip.taxon.label.replace("<STR_LIT:U+0020>", "<STR_LIT:_>")<EOL>if tip.taxon.label in self.taxonomy:<EOL><INDENT>tax_string = '<STR_LIT>'.join(self.taxonomy[tax_name])<EOL><DEDENT>else:<EOL><INDENT>ancestor_list = []<EOL>for ancestor in tip.ancestor_iter():<EOL><INDENT>if ancestor.label:<EOL><INDENT>split_node_name = ancestor.label.split('<STR_LIT::>')<EOL>if len(split_node_name) == <NUM_LIT:2>:<EOL><INDENT>ancestor_list+=list(reversed(split_node_name[<NUM_LIT:1>].split('<STR_LIT>')))<EOL><DEDENT>elif len(split_node_name) == <NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>float(split_node_name[<NUM_LIT:0>])<EOL><DEDENT>except ValueError:<EOL><INDENT>ancestor_list+=list(reversed(split_node_name[<NUM_LIT:0>].split('<STR_LIT>')))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % ancestor.label)<EOL><DEDENT><DEDENT><DEDENT>tax_list = list(reversed(ancestor_list))<EOL>if len(tax_list) < <NUM_LIT:1>:<EOL><INDENT>logging.warning("<STR_LIT>" % (tax_name))<EOL>tax_string = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>tax_string = '<STR_LIT>'.join(tax_list)<EOL><DEDENT><DEDENT>output_line = "<STR_LIT>" % (tax_name, tax_string)<EOL>out.write(output_line)<EOL><DEDENT><DEDENT>
Writes the taxonomy of each leaf to a file. If the leaf has no
taxonomy, a taxonomy string will be created using the annotations
provided to the ancestor nodes of that leaf (meaning, it will be
decorated).

Parameters
----------
output    : string
    File to which the taxonomy strings for each leaf in the tree will
    be written in Greengenes format, e.g.
        637960147    mcrA; Euryarchaeota_mcrA; Methanomicrobia
        637699780    mcrA; Euryarchaeota_mcrA; Methanomicrobia