def rename_proteins(prot_in, prot_out=None, chunk_size=DEFAULT_CHUNK_SIZE):
if prot_out is None:<EOL><INDENT>prot_out = "<STR_LIT>".format(prot_in.split("<STR_LIT:.>")[<NUM_LIT:0>])<EOL><DEDENT>with open(prot_out, "<STR_LIT:w>") as prot_out_handle:<EOL><INDENT>for record in SeqIO.parse(prot_in, "<STR_LIT>"):<EOL><INDENT>header = record.description<EOL>name, pos_start, _, _, _ = header.split("<STR_LIT:#>")<EOL>chunk_start = int(pos_start) // chunk_size<EOL>name_split = name.split("<STR_LIT:_>")<EOL>contig_name = "<STR_LIT:_>".join(name_split[:-<NUM_LIT:1>])<EOL>gene_id = name_split[-<NUM_LIT:1>]<EOL>new_record_id = "<STR_LIT>".format(<EOL>contig_name, chunk_start, gene_id<EOL>)<EOL>prot_out_handle.write("<STR_LIT>".format(new_record_id))<EOL>prot_out_handle.write("<STR_LIT>".format(str(record.seq)))<EOL><DEDENT><DEDENT>
Rename prodigal output files

    Rename output files from prodigal according to the following naming
    scheme: >contigX_chunkY__geneZ

    Chunk numbering starts at 0 and gene identification is taken from prodigal.

    Parameters
    ----------
    prot_in : file, str or pathlib.Path
        The input protein file in FASTA format to be renamed.
    prot_out : file, str or pathlib.Path
        The output protein file to be renamed into.
    chunk_size : int, optional
        The size of the chunks (in bp) used in the pipeline. Default is 1000.