mutagenize
Introduce point mutations into every sequence in a pool. Exactly one of
num_mutations or mutation_rate must be supplied. Pass region to
restrict mutagenesis to a named tagged segment; use allowed_chars to limit
which substitutions are permitted.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
The Pool to mutagenize. Can also be a plain sequence string. |
|
|
|
Fixed number of point mutations per draw. Mutually exclusive with
|
|
|
|
Per-base probability of mutation. Each base is mutated independently
with this probability. Mutually exclusive with |
|
|
|
Name of a tagged region to restrict mutations to. Flanks are unchanged. |
|
|
|
IUPAC string of the same length as the sequence specifying the allowed bases at each position. Only positions with more than one allowed base are mutable. |
|
|
|
Named display style applied to mutated bases. |
|
|
|
Prefix for auto-generated sequence names. |
|
|
|
|
|
|
|
Fix the total number of output states. |
|
|
|
Dimension-name ordering for downstream multi-pool iteration. |
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see mutagenize() in the
API Reference.
Examples
Single random mutation (num_mutations=1)
Each draw returns one sequence with a single substitution at a randomly chosen position.
wt = pp.from_seq("ATCGATCG")
mutants = wt.mutagenize(num_mutations=1, mode="random", style="red")
mutants.print_library()
Multiple independent mutants with num_states
Pass num_states to draw multiple independent single-mutant sequences in
one generate_library call.
wt = pp.from_seq("ATCGATCG")
mutants = wt.mutagenize(num_mutations=1, num_states=5, mode="random", style="red")
mutants.print_library()
ATCGATCT
ATCGCTCG
ATCGAACG
ATCGATGG
Per-base mutation rate (mutation_rate=0.1)
mutation_rate applies an independent per-position probability; the number
of substitutions per draw follows a Binomial distribution and may be zero.
wt = pp.from_seq("ATCGATCG")
mutants = wt.mutagenize(mutation_rate=0.1, mode="random", style="red")
mutants.print_library()
Mutate only within a named region
region confines all mutations to the tagged segment; flanks are returned
unchanged. With mode='sequential', every single-base variant within the
region is enumerated.
wt = pp.from_seq("AAAA<cre>ATCGATCG</cre>TTTT")
mutants = wt.mutagenize(num_mutations=1, region="cre", mode="sequential",
style="red")
mutants.print_library()
AAAA<cre>GTCGATCG</cre>TTTT
AAAA<cre>TTCGATCG</cre>TTTT
AAAA<cre>AACGATCG</cre>TTTT
AAAA<cre>ACCGATCG</cre>TTTT ... (24 total)
Restrict substitutions with allowed_chars
allowed_chars="SSSSSSSS" (S = {G,C}) restricts mutations to G↔C
swaps at every position; no A or T substitutions are made.
mode='sequential' enumerates every allowed swap.
wt = pp.from_seq("GCGCGCGC")
mutants = wt.mutagenize(num_mutations=1, allowed_chars="SSSSSSSS",
mode="sequential", style="red")
mutants.print_library()
GGGCGCGC
GCCCGCGC
GCGGGCGC
GCGCCCGC
GCGCGGGC
GCGCGCCC
GCGCGCGG
Sequential enumeration (mode=”sequential”)
mode='sequential' with num_mutations=1 enumerates every single-point
variant in deterministic order, covering all positions and non-wild-type bases.
wt = pp.from_seq("ACGT")
mutants = wt.mutagenize(num_mutations=1, mode="sequential", style="red")
mutants.print_library()
GCGT
TCGT
AAGT
AGGT ... (12 total)
See mutagenize().