replacement_multiscan
Place multiple non-overlapping replacement windows simultaneously at randomly chosen positions, producing combinatorial libraries with paired substitutions.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Input pool or sequence string. |
|
|
(required) |
Number of simultaneous non-overlapping replacement windows per draw. |
|
|
(required) |
Pool(s) supplying replacement content. A single pool is reused at every site; a list assigns one pool per site. |
|
|
|
Allowed position sets for each replacement window. |
|
|
|
Named region or interval to restrict replacements to. |
|
|
|
Names for each replacement window. |
|
|
|
Display style for replaced content. |
|
|
|
|
|
|
|
Minimum gap (in bases) between replacement windows. |
|
|
|
Maximum gap (in bases) between replacement windows. |
|
|
|
Prefix for the operation node name in the pool graph. |
|
|
|
|
|
|
|
Number of states. |
|
|
|
Enumeration order when combined with other pools. |
|
|
|
Design card columns to include in library output. |
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see replacement_multiscan() in the
API Reference.
Examples
Two simultaneous replacements
Draw two non-overlapping single-base substitution positions at random per sequence.
wt = pp.from_seq("ATCGATCGATCG")
alt = pp.from_seqs(["A", "C", "G", "T"], mode="sequential")
scan = wt.replacement_multiscan(num_replacements=2,
replacement_pools=alt, mode="random",
style="red")
scan.print_library()
ATCGATCGATCC
ATCGATAGATCG
ATCGATCGTTCG
ATCGACCGAACG ... (16 total)
Two simultaneous degenerate motif replacements
Replace with a degenerate 6-base IUPAC motif (R = A|G, Y = C|T) at
two random positions on a 24-mer. Each draw samples independently from the
64 possible RRYYYY sequences.
wt = pp.from_seq("ATCGATCGATCGATCGATCGATCG")
motif = pp.from_iupac("RRYYYY")
scan = wt.replacement_multiscan(num_replacements=2,
replacement_pools=motif, mode="random",
style="red")
scan.print_library()
Multiscan within a named region
Restrict both replacement windows to the cre region; flanking bases are
never touched.
wt = pp.from_seq("AAAA<cre>ATCGATCGATCG</cre>TTTT")
alt = pp.from_seqs(["A", "C", "G", "T"], mode="sequential")
scan = wt.replacement_multiscan(num_replacements=2,
replacement_pools=alt,
region="cre", mode="random",
style="red")
scan.print_library()
AAAA<cre>ATCGATCGATCC</cre>TTTT
AAAA<cre>ATCGATAGATCG</cre>TTTT
AAAA<cre>ATCGATCGTTCG</cre>TTTT
AAAA<cre>ATCGACCGAACG</cre>TTTT ... (16 total)
Spacing constraints (min_spacing, max_spacing)
min_spacing and max_spacing control the gap between replacement
windows. Here two 6-base motif replacements must be 3–6 bases apart on a
24-mer.
wt = pp.from_seq("ATCGATCGATCGATCGATCGATCG")
motif = pp.from_seq("GATTAC")
scan = wt.replacement_multiscan(num_replacements=2,
replacement_pools=motif,
min_spacing=3, max_spacing=6,
mode="sequential", style="red")
scan.print_library()
GATTACCGATGATTACATCGATCG
GATTACCGATCGATTACTCGATCG
GATTACCGATCGGATTACCGATCG
AGATTACGATGATTACATCGATCG ... (34 total)
PPM-based replacement pool (from_motif)
Use from_motif() to supply a position-probability matrix
as the replacement content. Each draw samples a different 6-mer from the
PPM, producing biologically realistic variation at each window.
import pandas as pd
pfm = pd.DataFrame({
"A": [0.8, 0.1, 0.5, 0.1, 0.7, 0.1],
"C": [0.1, 0.7, 0.2, 0.1, 0.1, 0.1],
"G": [0.05, 0.1, 0.2, 0.1, 0.1, 0.7],
"T": [0.05, 0.1, 0.1, 0.7, 0.1, 0.1],
})
wt = pp.from_seq("ATCGATCGATCGATCGATCGATCG")
motif = pp.from_motif(pfm)
scan = wt.replacement_multiscan(num_replacements=2,
replacement_pools=motif, mode="random",
num_states=5, style="red")
scan.print_library()
CCATATCGATCGATCGAAGGCATG
ATCGATCGATCCGCAGAAAATAGG
CCATATCGATCGAACATAGGATCG
ATCGATCGACATAGCACATACTCG
Explicit position sets (positions)
Specify allowed starts for each window independently, using a distinct pool
for each site. Below, the first replacement (GGG) can start at position
0, 3, or 6, while the second (AAA) can start at position 9 or 13.
wt = pp.from_seq("ATCGATCGATCGATCG")
pools = [pp.from_seq("GGG"), pp.from_seq("AAA")]
scan = wt.replacement_multiscan(num_replacements=2,
replacement_pools=pools,
positions=[[0, 3, 6], [9, 13]],
mode="sequential", style="red")
scan.print_library()
GGGGATCGATCGAAAA
ATCGGGCGAAAAATCG
ATCGGGCGATCGAAAA
ATCGATGGGAAAATCG
ATCGATGGGTCGAAAA