replace_region
==============
Replace the entire content of a named region with sequences drawn from a
content pool. By default, background and content states are paired 1:1
(``sync=True``) and region tags are preserved (``keep_tags=True``).
Set ``sync=False`` for a Cartesian product and ``keep_tags=False`` to
strip the region tags.
.. code-block:: python
import poolparty as pp
pp.init()
----
Parameters
----------
.. list-table::
:header-rows: 1
:widths: auto
* - Parameter
- Type
- Default
- Description
* - ``pool``
- ``Pool | str``
- *(required)*
- The background Pool or sequence string whose named region will be
replaced.
* - ``content_pool``
- ``Pool``
- *(required)*
- Pool whose sequences replace the region content.
* - ``region_name``
- ``str``
- *(required)*
- Name of the region to replace (must exist in the background pool).
* - ``rc``
- ``bool``
- ``False``
- When ``True``, reverse-complement each content sequence before
inserting it.
* - ``sync``
- ``bool``
- ``True``
- When ``True``, pair background and content states 1:1 (lockstep
iteration) instead of taking the Cartesian product.
* - ``keep_tags``
- ``bool``
- ``True``
- When ``True``, preserve the region tags around the replaced content
so the region can still be referenced by downstream operations.
* - ``iter_order``
- ``int | None``
- ``None``
- Enumeration order when combined with other pools.
* - ``prefix``
- ``str | None``
- ``None``
- 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 :func:`~poolparty.replace_region` in the
:doc:`API Reference `.
Examples
--------
Pair each background with its own insert
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When both pools have the same number of states, the default ``sync=True``
pairs them 1:1. Tags are preserved (``keep_tags=True``) so the region can
be referenced by later operations.
.. code-block:: python
backgrounds = pp.from_seqs(
["AAAA