def rename_genome(genome_in, genome_out=None):
if genome_out is None:<EOL><INDENT>genome_out = "<STR_LIT>".format(genome_in.split("<STR_LIT:.>")[<NUM_LIT:0>])<EOL><DEDENT>with open(genome_out, "<STR_LIT:w>") as output_handle:<EOL><INDENT>for record in SeqIO.parse(genome_in, "<STR_LIT>"):<EOL><INDENT>new_record_id = record.id.replace("<STR_LIT:U+0020>", "<STR_LIT:_>")<EOL>new_record_id = new_record_id.replace("<STR_LIT:->", "<STR_LIT:_>")<EOL>new_record_id = new_record_id.replace("<STR_LIT:\t>", "<STR_LIT:_>")<EOL>new_record_id = re.sub("<STR_LIT>", "<STR_LIT>", new_record_id)<EOL>header = "<STR_LIT>".format(new_record_id)<EOL>output_handle.write(header)<EOL>output_handle.write("<STR_LIT>".format(str(record.seq)))<EOL><DEDENT><DEDENT>
Rename genome and slugify headers

    Rename genomes according to a simple naming scheme; this
    is mainly done to avoid special character weirdness.

    Parameters
    ----------
    genome_in : file, str or pathlib.Path
        The input genome to be renamed and slugify.
    genome_out : file, str or pathlib.Path
        The output genome to be written into. Defaults is <base>_renamed.fa,
        where <base> is genome_in without its extension.