shuffle_scan
Slide a window of fixed length across the sequence (or a named region) and,
at each position, shuffle the bases within that window. Bases outside the window
are unchanged. Use mode='sequential' to enumerate every window start as its
own state; mode='random' (the default) samples window positions according to
num_states (default 1 for a single draw). Pair with
shuffles_per_position to list several independent shuffles per draw.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
The Pool to scan. Can also be a plain sequence string. |
|
|
(required) |
Width of the shuffle window in bases. A sequence of length L
produces L - |
|
|
|
Explicit list of window start positions. |
|
|
|
Name of a tagged region to restrict the scan to. Flanks are never modified. |
|
|
|
|
|
|
|
Number of independent shuffles generated per window position. Values > 1 multiply the library size by that factor. |
|
|
|
Prefix for auto-generated sequence names. |
|
|
|
|
|
|
|
Fix the total number of output states. |
|
|
|
Named display style applied to the shuffled window. |
|
|
|
Controls which axis varies fastest when |
Note
With shuffle_type="dinuc", the first and last bases of each window
are always fixed — this is a mathematical constraint of the Euler-path
algorithm used to preserve dinucleotide frequencies.
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see shuffle_scan() in the
API Reference.
Examples
3-base shuffle window across an 8-mer
Six starts are valid for a length-3 window on an 8-mer. With mode='random'
and default num_states, the pool has a single state, so print_library()
shows one shuffled draw (reproducible after pp.init() with default library
generation seeding).
import poolparty as pp
pp.init()
wt = pp.from_seq("ACGTACGT")
scan = wt.shuffle_scan(shuffle_length=3, mode="random", style="red")
scan.print_library()
Multiple shuffles per position (shuffles_per_position)
shuffles_per_position=3 attaches three independent shuffles to the drawn
window; the preview lists each of the three pool states.
import poolparty as pp
pp.init()
wt = pp.from_seq("ACGTACGT")
scan = wt.shuffle_scan(shuffle_length=3, shuffles_per_position=3, mode="random",
style="red")
scan.print_library()
ACGTACGT
ACGTCAGT
Explicit position list
Pass positions=[0, 3, 6] so the shuffle window may start only at those
indices. With mode='random' and default num_states, one of those starts
is drawn per state (here the preview is a single row).
import poolparty as pp
pp.init()
wt = pp.from_seq("ACGTACGT")
scan = wt.shuffle_scan(shuffle_length=2, positions=[0, 3, 6], mode="random",
style="red")
scan.print_library()
Shuffle scan within a named region
Restrict the scan to the cre region; flanking sequences are never
shuffled. Literal tags appear in the printed sequence; below they are escaped
for HTML.
import poolparty as pp
pp.init()
wt = pp.from_seq("AAAA<cre>ATCGATCG</cre>TTTT")
scan = wt.shuffle_scan(shuffle_length=3, region="cre", mode="random",
style="red")
scan.print_library()
Sequential mode — all window positions
mode='sequential' enumerates every window start position left-to-right,
producing one shuffled state per position. With a 3-base window on an 8-mer,
there are 6 positions.
import poolparty as pp
pp.init()
wt = pp.from_seq("ACGTACGT")
scan = wt.shuffle_scan(shuffle_length=3, mode="sequential", style="red")
scan.print_library()
ACGTACGT
ACGATCGT
ACGCATGT
ACGTACGT
ACGTATGC
See shuffle_scan().