reverse_translate
Convert a protein pool (or a protein sequence string) to a DNA pool by
back-translating each amino acid to a codon. Two selection strategies are
available: "first" always picks the most frequent codon (deterministic),
while "random" samples from all synonymous codons (stochastic).
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
A |
|
|
|
Restrict translation to a named region or |
|
|
|
|
|
|
|
Number of states. Only relevant with |
|
|
|
Genetic code to use. Pass a string identifier or a custom codon dictionary. |
|
|
|
Enumeration order when combined with other pools. |
|
|
|
Prefix for the operation node name in the pool graph. |
Note
The output sequence length is always 3 × the protein length (each amino acid maps to exactly one codon).
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see reverse_translate() in the
API Reference.
Examples
Deterministic back-translation
codon_selection="first" (the default) always picks the same codon for
each amino acid, producing a single fixed DNA sequence.
dna = pp.reverse_translate("MKTL")
dna.print_library()
Stochastic back-translation
codon_selection="random" samples from synonymous codons, so each draw
may produce a different DNA sequence encoding the same protein.
dna = pp.reverse_translate("MKTL", codon_selection="random", num_states=4)
dna.print_library()
ATGAAAACGTTA
ATGAAAACGCTC
ATGAAGACGTTA
Chain: translate then reverse-translate
Round-trip a DNA sequence through protein and back — the resulting DNA may differ due to codon degeneracy, but the encoded protein is identical.
dna = pp.from_seq("ATGAAACCCGGG")
protein = pp.translate(dna)
back = pp.reverse_translate(protein, codon_selection="first")
back.print_library()
See reverse_translate().