translate

Translate a DNA pool into a protein pool using the standard genetic code. Pass region= to translate only a named ORF segment; include_stop=False omits the trailing stop codon from the output.

import poolparty as pp
pp.init()

Parameters

Parameter

Type

Default

Description

pool

Pool | str

(required)

DNA pool or plain sequence string to translate.

region

str | Sequence[int] | None

None

Region name (from annotate_orf) or [start, stop] interval. None translates the full sequence.

frame

int | None

None

Reading frame (+1+3, -1-3). For a named OrfRegion, defaults to the region’s frame; otherwise +1.

include_stop

bool

True

When True, include the stop codon as * in the protein.

preserve_codon_styles

bool

True

If True, copy nucleotide styles to amino acids when all three bases of a codon share the same style.

genetic_code

str | dict

"standard"

Built-in code name or a custom codon table mapping.

iter_order

float | None

None

Enumeration order when combined with other pools.

prefix

str | None

None

Prefix for sequence names in the resulting pool.


Note

Only the most commonly used parameters are shown above. For the full parameter list, see translate() in the API Reference.

Examples

Translate a 5-codon CDS

Translate the 15-nucleotide sequence ATGAAATTTGGGCCC to the 5-residue peptide M-K-F-G-P.

cds     = pp.from_seq("ATGAAATTTGGGCCC")
protein = pp.translate(cds)
protein.print_library()
protein: seq_length=5, num_states=1 MKFGP

Translate a mutagenized CDS pool

Chain mutagenize_orf with translate. When mutagenize_orf applies style="red", translate preserves that style on the resulting amino acid (controlled by preserve_codon_styles, default True).

cds     = pp.from_seq("ATGAAATTTGGGCCC")
mutants = pp.mutagenize_orf(cds, num_mutations=1, mode="random", style="red")
protein = pp.translate(mutants)
protein.print_library()
protein: seq_length=5, num_states=1 MKWGP
MTFGP
MKFGR
LKFGP ... (stochastic; mutated residue highlighted)

Translate only the ORF region within a longer sequence

When the CDS is embedded in flanking UTR context, tag it with annotate_orf and pass the region name to translate so only the annotated ORF is translated.

seq  = pp.from_seq("TATAATGAAATTTGGGCCCTAA")
seq  = pp.annotate_orf(seq, "gene", extent=(4, 19))
prot = pp.translate(seq, region="gene", include_stop=False)
prot.print_library()
prot: seq_length=None, num_states=1 MKFGP

See translate().