stylize_orf

Apply codon-aware inline styling to sequences without modifying them. Pass style_codons= to cycle a list of styles across whole codons, or style_frames= (length a multiple of 3) to style each base position within a codon independently. Use region= to restrict coloring to a named ORF segment. Use mode='sequential' to preserve all upstream states.

import poolparty as pp
pp.init()

Parameters

Parameter

Type

Default

Description

pool

Pool | str

(required)

The Pool or sequence string to style.

region

str | list | None

None

Restrict styling to a named ORF region or a [start, stop] coordinate pair. The region must be an OrfRegion (created by annotate_orf) or frame must be specified explicitly.

style_codons

list[str] | None

None

List of style names cycled across whole codons. Mutually exclusive with style_frames.

style_frames

list[str] | None

None

List of style names (length a multiple of 3) applied per base position within each codon. Mutually exclusive with style_codons.

frame

int | None

None

Reading frame (+1..+3 or -1..-3). Auto-detected from an OrfRegion if region is set; must be specified otherwise.

prefix

str | None

None

Prefix for the operation node name in the pool graph.

iter_order

float | None

None

Enumeration order when combined with other pools.


Note

Only the most commonly used parameters are shown above. For the full parameter list, see stylize_orf() in the API Reference.

Examples

Alternating codon colours (style_codons)

Cycle two colours across the 5 codons of ATGAAATTTGGGCCC so the reading frame is immediately visible.

cds    = pp.from_seq("ATGAAATTTGGGCCC")
styled = pp.stylize_orf(cds, style_codons=["blue", "red"])
styled.print_library()
styled: seq_length=15, num_states=1 ATGAAATTTGGGCCC

Per-base position styling (style_frames)

Colour each position within a codon independently — each of the three codon positions gets its own colour — to highlight wobble positions.

cds    = pp.from_seq("ATGAAATTTGGGCCC")
styled = pp.stylize_orf(cds, style_frames=["blue", "red", "green"])
styled.print_library()
styled: seq_length=15, num_states=1 ATGAAATTTGGGCCC

Restrict styling to a named ORF region

Use annotate_orf to register the reading frame, then stylize_orf with region= to colour only the ORF while leaving flanking bases unstyled.

wt     = pp.from_seq("AAAA<cds>ATGAAATTTGGGCCC</cds>TTTT")
orf    = pp.annotate_orf(wt, "cds")
styled = pp.stylize_orf(orf, region="cds",
                         style_codons=["blue", "red"])
styled.print_library()
styled: seq_length=23, num_states=1 AAAA<cds>ATGAAATTTGGGCCC</cds>TTTT

See stylize_orf().