def write_taxonomy_and_seqinfo_files(self, taxonomies, output_taxonomy_file, output_seqinfo_file):
first_pass_id_and_taxonomies = []<EOL>tc=TaxonomyCleaner()<EOL>max_number_of_ranks = <NUM_LIT:0><EOL>for taxon_id, tax_split in taxonomies.items():<EOL><INDENT>for idx, item in enumerate(tax_split):<EOL><INDENT>tax_split[idx] = re.sub('<STR_LIT>', '<STR_LIT:_>', item.strip())<EOL><DEDENT>tax_split = tc.remove_empty_ranks(tax_split)<EOL>first_pass_id_and_taxonomies.append([taxon_id]+tax_split)<EOL>if len(tax_split) > max_number_of_ranks:<EOL><INDENT>max_number_of_ranks = len(tax_split)<EOL><DEDENT><DEDENT>parents = {} <EOL>known_duplicates = sets.Set([])<EOL>for j, array in enumerate(first_pass_id_and_taxonomies):<EOL><INDENT>taxonomy = array[<NUM_LIT:1>:]<EOL>for i, tax in enumerate(taxonomy):<EOL><INDENT>if i==<NUM_LIT:0>: continue <EOL>ancestry = taxonomy[i-<NUM_LIT:1>]<EOL>if tax in parents:<EOL><INDENT>if parents[tax] != ancestry:<EOL><INDENT>dup = "<STR_LIT>" %(parents[tax], ancestry)<EOL>if dup not in known_duplicates:<EOL><INDENT>print("<STR_LIT>" % (array[<NUM_LIT:0>], tax, parents[tax], ancestry))<EOL>known_duplicates.add(dup)<EOL><DEDENT>new_name_id = <NUM_LIT:1><EOL>new_name = "<STR_LIT>" % (tax, new_name_id)<EOL>while new_name in parents and parents[new_name] != ancestry:<EOL><INDENT>new_name_id += <NUM_LIT:1><EOL>new_name = "<STR_LIT>" % (tax, new_name_id)<EOL><DEDENT>first_pass_id_and_taxonomies[j][i+<NUM_LIT:1>] = new_name<EOL>taxonomy[i] = new_name<EOL>parents[new_name] = ancestry<EOL><DEDENT><DEDENT>else:<EOL><INDENT>parents[tax] = ancestry<EOL><DEDENT><DEDENT><DEDENT>with open(output_seqinfo_file, '<STR_LIT:w>') as seqout:<EOL><INDENT>seqout.write('<STR_LIT>')<EOL>for array in first_pass_id_and_taxonomies:<EOL><INDENT>sequence_id = array[<NUM_LIT:0>]<EOL>if len(array)==<NUM_LIT:1>:<EOL><INDENT>most_specific_taxonomic_affiliation = '<STR_LIT>'<EOL><DEDENT>else:  <EOL><INDENT>most_specific_taxonomic_affiliation = array[-<NUM_LIT:1>]<EOL><DEDENT>seqout.write("<STR_LIT>" % (array[<NUM_LIT:0>], <EOL>most_specific_taxonomic_affiliation))<EOL><DEDENT><DEDENT>noted_taxonomies = sets.Set([])<EOL>taxonomic_level_names = ["<STR_LIT>" % rank for rank in range(max_number_of_ranks)]<EOL>with open(output_taxonomy_file, '<STR_LIT:w>') as seqout:<EOL><INDENT>seqout.write('<STR_LIT:U+002C>'.join(['<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT:root>'] + taxonomic_level_names) +'<STR_LIT:\n>')<EOL>seqout.write('<STR_LIT:U+002C>'.join(['<STR_LIT>','<STR_LIT>','<STR_LIT:root>','<STR_LIT>','<STR_LIT>'])+ '<STR_LIT>'.join(['<STR_LIT:U+002C>']*max_number_of_ranks) + '<STR_LIT:\n>')<EOL>for array in first_pass_id_and_taxonomies:<EOL><INDENT>taxons = array[<NUM_LIT:1>:]<EOL>for i, tax in enumerate(taxons):<EOL><INDENT>line = self._taxonomy_line(i, taxons[:(i+<NUM_LIT:1>)], taxonomic_level_names)<EOL>if line not in noted_taxonomies:<EOL><INDENT>seqout.write(line+"<STR_LIT:\n>")<EOL>noted_taxonomies.add(line)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Write out taxonomy and seqinfo files as required by taxtastic
        from known taxonomies

        Parameters
        ----------
        taxonomies:
            hash of taxon_id to array of taxonomic information
        output_taxonomy_file:
            write taxtastic-compatible 'taxonomy' file here
        output_seqinfo_file:
            write taxtastic-compatible 'seqinfo' file here