flip
Produce forward and reverse-complement variants of a pool as distinct
states. Unlike rc() (which always reverses), flip
tracks orientation as part of the pool’s state dimension: sequential
mode enumerates both orientations deterministically; random mode
coin-flips each draw with a configurable probability.
import poolparty as pp
pp.init()
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
The background Pool or sequence string. Must be a DNA pool. |
|
|
|
Region to flip. A named tag (str), |
|
|
|
Probability of reverse complement in random mode. Ignored in sequential mode. |
|
|
|
Prefix for auto-generated sequence names. |
|
|
|
|
|
|
|
Override the natural state count. In sequential mode the natural
count is 2 (cycling if greater). In random mode, |
|
|
|
Enumeration order when combined with other pools. |
|
|
|
Display style applied to the reverse-complemented variant only. |
|
|
|
Design card keys to include. Available key: |
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see flip() in the
API Reference.
Examples
Sequential mode — both orientations
mode='sequential' produces two states: forward then RC.
wt = pp.from_seq("ATCGATCG")
flipped = wt.flip(mode="sequential", style="red")
flipped.print_library()
CGATCGAT
Random mode with custom rc_prob
mode='random' samples orientation per draw. Here rc_prob=0.3
means 30% chance of RC on each draw.
wt = pp.from_seq("ATCGATCG")
flipped = wt.flip(mode="random", rc_prob=0.3, num_states=5, style="red")
flipped.print_library()
ATCGATCG
ATCGATCG
ATCGATCG
CGATCGAT
Flip only a named region
region restricts the RC operation to a tagged segment; flanks are
returned unchanged.
wt = pp.from_seq("AAAA<cre>ATCGATCG</cre>TTTT")
flipped = wt.flip(region="cre", style="red")
flipped.print_library()
AAAA<cre>CGATCGAT</cre>TTTT
Flip a multi-state pool
Flipping a pool with multiple states doubles the library: each variant appears once in the forward orientation and once reverse-complemented.
variants = pp.from_seqs(["AACG", "TTAG", "GCCA"], mode="sequential")
both = variants.flip(style="red")
both.print_library()
CGTT
TTAG
CTAA
GCCA
TGGC
See flip().