annotate_region

Tag a region by position range and optionally apply a display style in one step. If the named region already exists in the pool, extent must be None (the existing bounds are kept) but a new style can still be applied.

import poolparty as pp
pp.init()

Parameters

Parameter

Type

Default

Description

pool

Pool

(required)

The Pool to annotate.

region_name

str

(required)

Name for the region (e.g. 'cre', 'orf').

extent

tuple[int, int] | None

None

(start, stop) tuple (0-based, exclusive stop). When None and the region does not yet exist, the entire sequence is annotated. Must be None if the region already exists.

style

str | None

None

Named display style applied to the region (e.g. 'blue bold'). None leaves the display unchanged.

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 annotate_region() in the API Reference.

Examples

Annotate by extent with no style

Mark positions 4–12 as the cre region with default rendering.

wt        = pp.from_seq("AAAAATCGATCGTTTT")
annotated = pp.annotate_region(wt, "cre", extent=(4, 12))
annotated.print_library()
annotated: seq_length=16, num_states=1 AAAA<cre>ATCGATCG</cre>TTTT

Annotate entire sequence (extent omitted)

Omit extent to tag the full sequence as a single named region.

wt        = pp.from_seq("ATCGATCG")
annotated = pp.annotate_region(wt, "full")
annotated.print_library()
annotated: seq_length=8, num_states=1 <full>ATCGATCG</full>

Annotate with a named style

style inserts the tag and applies a colour/weight in one call.

wt        = pp.from_seq("AAAAATCGATCGTTTT")
annotated = pp.annotate_region(wt, "cre", extent=(4, 12),
                               style="green bold")
annotated.print_library()
annotated: seq_length=16, num_states=1 AAAA<cre>ATCGATCG</cre>TTTT

Two regions with different styles

Chain two calls to give adjacent segments distinct colours.

wt    = pp.from_seq("AAAAATCGGGGGCCCTTTT")
step1 = pp.annotate_region(wt,    "left",  extent=(4, 8),   style="blue bold")
step2 = pp.annotate_region(step1, "right", extent=(13, 17), style="red bold")
step2.print_library()
step2: seq_length=19, num_states=1 AAAA<left>ATCG</left>GGGGC<right>CCTT</right>TT

Apply a style to an existing region (extent=None)

When the region already exists, omit extent and supply only style to add colour without re-tagging.

wt     = pp.from_seq("AAAA<cre>ATCGATCG</cre>TTTT")
styled = pp.annotate_region(wt, "cre", style="red")
styled.print_library()
styled: seq_length=16, num_states=1 AAAA<cre>ATCGATCG</cre>TTTT

See annotate_region().