shuffle_states
Randomly permute the order of a pool’s state space, optionally with a fixed seed for deterministic shuffling, while leaving the sequences themselves unchanged.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Input pool whose state order will be shuffled. |
|
|
|
Random seed for deterministic shuffling. |
|
|
|
Explicit permutation of state indices. Overrides |
|
|
|
Prefix for the operation node name in the pool graph. |
|
|
|
Enumeration order when combined with other pools. |
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see state_shuffle() in the
API Reference.
Examples
Shuffle All 16 2-mer States with a Fixed Seed
Reorder the 16 2-mers produced by get_kmers using seed=0 so that the
permutation is deterministic and reproducible.
kmers = pp.get_kmers(length=2, mode="sequential")
shuffled = pp.state_shuffle(kmers, seed=0)
shuffled.print_library()
TG
CC
AC
GC ... (16 total)
Shuffle Then Slice to Get a Random Subset
Combine state_shuffle with state_slice to draw a reproducible random
subset without replacement — equivalent to a seeded random sample.
kmers = pp.get_kmers(length=2, mode="sequential")
shuffled = pp.state_shuffle(kmers, seed=0)
subset = pp.state_slice(shuffled, slice(0, 6))
subset.print_library()
TG
CC
AC
GC
AG
Two Shuffles with Different Seeds Produce Different Orders
Changing the seed produces an independent permutation, demonstrating that the output order is fully determined by the seed value.
kmers = pp.get_kmers(length=2, mode="sequential")
shuffled_0 = pp.state_shuffle(kmers, seed=0)
shuffled_0.print_library()
shuffled_1 = pp.state_shuffle(kmers, seed=1)
shuffled_1.print_library()
TG
CC
AC
GC ... (16 total)
GG
AA
TG
CG ... (16 total)
See state_shuffle().