slice_seq
Extract a subsequence using Python-style slicing, a named region, or both.
When keep_context=True, the sliced content is reassembled into the
original flanking context.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Input pool or sequence string. |
|
|
|
Region to slice from. A string selects a named region; a
|
|
|
|
Start index (0-based, Python-style). Applied after region
extraction when |
|
|
|
Stop index (exclusive, Python-style). |
|
|
|
Step size (Python-style). |
|
|
|
If |
|
|
|
Iteration priority for downstream multi-pool iteration. |
|
|
|
Prefix for the operation node name in the pool graph. |
|
|
|
Display style applied to the sliced output. |
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see slice_seq() in the
API Reference.
Examples
Slice by position
Extract bases 2–6 from an 8-mer.
pool = pp.from_seq("ACGTACGT")
sliced = pp.slice_seq(pool, start=2, stop=6)
sliced.print_library()
Extract a named region
Pull the content of a tagged region into its own pool.
pool = pp.from_seq("AAA<orf>ATGCCC</orf>TTT")
orf = pp.slice_seq(pool, region="orf")
orf.print_library()
Slice within a named region
Combine region with start/stop to slice inside the region. Here,
take only the first codon.
pool = pp.from_seq("AAA<orf>ATGCCC</orf>TTT")
codon1 = pp.slice_seq(pool, region="orf", start=0, stop=3)
codon1.print_library()
Keep context — reassemble flanks
With keep_context=True the sliced region content is placed back into the
original flanking sequence.
pool = pp.from_seq("AAA<orf>ATGCCC</orf>TTT")
sliced = pp.slice_seq(pool, region="orf", start=0, stop=3, keep_context=True)
sliced.print_library()
See slice_seq().