sync
Synchronize multiple pools so they iterate in lockstep — state i of every
synced pool is always drawn together. This is an in-place operation
(it modifies the pools and returns None).
import poolparty as pp
pp.init()
Note
All synced pools must have the same number of states, and no pool may be an ancestor of another in the DAG (which would create a circular dependency).
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Pools to synchronize. Must all have the same |
Returns None — pools are modified in-place.
Note
Only the most commonly used parameters are shown above. For the full
parameter list, see sync() in the
API Reference.
Examples
Without sync: Cartesian product
By default, joining two pools produces every combination of their states. Two 3-state pools yield 3 × 3 = 9 sequences.
a = pp.from_seqs(["AAA", "CCC", "GGG"], mode="sequential")
b = pp.from_seqs(["TTT", "AAA", "CCC"], mode="sequential")
cross = pp.join([a, b])
cross.print_library()
AAAAAA
AAACCC
CCCTTT
CCCAAA
CCCCCC
GGGTTT
GGGAAA
GGGCCC
With sync: matched pairs
After syncing, the same join produces only the 3 matched pairs. State 0
of left is always drawn together with state 0 of right, and so on.
left = pp.from_seqs(["AAA", "CCC", "GGG"], mode="sequential")
right = pp.from_seqs(["TTT", "AAA", "CCC"], mode="sequential")
pp.sync([left, right])
paired = pp.join([left, right])
paired.print_library()
CCCAAA
GGGCCC
Pair variants with identifiers
A common use case is to assign each variant a unique identifier sequence so that the pairing is fixed across the library.
variants = pp.from_seqs(["ATCG", "GCTA", "TTAA", "CCGG"],
mode="sequential")
tags = pp.from_seqs(["AAAA", "CCCC", "GGGG", "TTTT"],
mode="sequential")
pp.sync([variants, tags])
library = pp.join([variants, tags])
library.print_library()
GCTACCCC
TTAAGGGG
CCGGTTTT
Sync three or more pools
sync accepts any number of pools. Here three 3-state pools are
synchronized, reducing the join from 27 combinations to 3 matched triples.
a = pp.from_seqs(["AAAA", "CCCC", "GGGG"], mode="sequential")
b = pp.from_seqs(["TTTT", "AAAT", "CCCT"], mode="sequential")
c = pp.from_seqs(["ACGT", "TGCA", "GATC"], mode="sequential")
pp.sync([a, b, c])
combined = pp.join([a, b, c])
combined.print_library()
CCCCAAATTGCA
GGGGCCCTGATC
See sync().