slice_states
Retain a contiguous slice of a pool’s state space using standard Python slice syntax, without altering the sequences themselves.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Input pool whose state space will be sliced. |
|
|
(required) |
Integer index (single state) or |
|
|
|
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_slice() in the
API Reference.
Examples
First 8 States of a 2-mer Pool
Take the first eight states of the 16-state 2-mer enumeration to obtain the
eight 2-mers that begin with A or C.
kmers = pp.get_kmers(length=2, mode="sequential")
first8 = pp.state_slice(kmers, slice(0, 8))
first8.print_library()
AC
AG
AT
CA
CC
CG
CT
Middle Slice: States 10–15
Select a window in the middle of the state space to focus on a particular sub-range of sequences without regenerating the entire pool.
kmers = pp.get_kmers(length=2, mode="sequential")
mid = pp.state_slice(kmers, slice(10, 15))
mid.print_library()
GT
TA
TC
TG
Last 4 States Using Negative Indexing
Negative indices count from the end of the state space, mirroring Python list slicing conventions.
kmers = pp.get_kmers(length=2, mode="sequential")
last4 = pp.state_slice(kmers, slice(-4, None))
last4.print_library()
TC
TG
TT
See state_slice().