sample ====== Draw a fixed number of sequences from a pool's state space, optionally with a random seed for reproducibility or with cycling when more sequences are requested than the pool contains. .. code-block:: python import poolparty as pp pp.init() ---- Parameters ---------- .. list-table:: :widths: auto :header-rows: 1 * - Parameter - Type - Default - Description * - ``pool`` - ``Pool`` - *(required)* - Input pool to sample from. * - ``num_seqs`` - ``int | None`` - ``None`` - Number of sequences to draw. Provide either ``num_seqs`` or ``seq_states``. * - ``seq_states`` - ``list[int] | None`` - ``None`` - Explicit list of state indices to select. Overrides ``num_seqs``. * - ``seed`` - ``int | None`` - ``None`` - Random seed for reproducible sampling. * - ``with_replacement`` - ``bool`` - ``True`` - If ``True``, states may be drawn more than once when ``num_seqs`` exceeds the pool's state count. * - ``prefix`` - ``str | None`` - ``None`` - Prefix for the operation node name in the pool graph. * - ``iter_order`` - ``float | None`` - ``None`` - Iteration priority for downstream multi-pool iteration. ---- .. note:: Only the most commonly used parameters are shown above. For the full parameter list, see :func:`~poolparty.sample` in the :doc:`API Reference `. Examples -------- Sample 5 Sequences from a 256-Sequence Pool ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Draw a small random subset from all 256 4-mers to obtain a manageable representative sample. Without a seed, which sequences appear changes on each evaluation. .. code-block:: python import poolparty as pp pp.init() kmers = pp.get_kmers(length=4, mode="sequential") subset = pp.sample(kmers, num_seqs=5) subset.print_library() .. raw:: html