apply_at_region
Apply an arbitrary Pool-to-Pool transform to the content of a named region,
leaving the flanking sequences unchanged. The function receives the region’s
content as a Pool and must return a
Pool. By default region tags are removed from the output;
set remove_tags=False to keep them.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
The Pool to apply the transform to. Can also be a plain sequence string. |
|
|
(required) |
Name of the region whose content to transform. |
|
|
(required) |
Callable |
|
|
|
When |
|
|
|
When |
|
|
|
Dimension-name ordering for downstream multi-pool iteration. |
|
|
|
Prefix for the operation node name in the pool graph. |
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see apply_at_region() in the
API Reference.
Examples
Uppercase a soft-masked region
p.upper() lifts a lowercase region to uppercase without touching the
flanking bases. Tags are removed by default.
wt = pp.from_seq("AAAA<cre>atcg</cre>TTTT")
uppercased = pp.apply_at_region(wt, "cre", lambda p: p.upper())
uppercased.print_library()
Reverse-complement a region
p.rc() reverse-complements only the region content (ATCG becomes
CGAT) while the flanking bases remain untouched.
wt = pp.from_seq("AAAA<cre>ATCG</cre>TTTT")
flipped = pp.apply_at_region(wt, "cre", lambda p: p.rc())
flipped.print_library()
Mutagenize within a region
Any Pool operation can serve as the transform. Here mutagenize with
mode='sequential' generates every single-base substitution inside the
region while the flanks stay wild-type.
wt = pp.from_seq("AAAA<cre>ATCG</cre>TTTT")
mutant = pp.apply_at_region(wt, "cre",
lambda p: p.mutagenize(num_mutations=1,
mode="sequential"))
mutant.print_library()
AAAAGTCGTTTT
AAAATTCGTTTT
AAAAAACGTTTT
AAAAACCGTTTT ... (12 total)
See apply_at_region().