When to Use
- DNA/RNA visualization: Display nucleotide sequences with standard colors (A=green, C=blue, G=orange, T/U=red)
- Tandem repeat analysis: Show BLADERUNNER strigar format repeat motifs
- Protein secondary structure: Visualize helix/strand/coil patterns
- Multiple sequence alignment: Compare sequences with positional coloring
- Any character-encoded data: When each position encodes a discrete state
Basic Example
Input Modes
Sequence Mode: with_sequences + with_template
Load raw character strings and color template.
Built-in Templates
BrickTemplate::new().dna() — Standard DNA colors:
- A →
rgb(0,150,0)(green) - C →
rgb(0,0,255)(blue) - G →
rgb(209,113,5)(orange) - T →
rgb(255,0,0)(red)
BrickTemplate::new().rna() — Standard RNA colors:
- A → green
- C → blue
- G → orange
- U → red
Custom Template
Strigar Mode: with_strigars
Load structured tandem-repeat motif data in BLADERUNNER format.
kmer:letter assignments (e.g. "CAT:A,C:B" binds CAT to local letter A).
Strigar string: run-length encoded local letters (e.g. "10A1B4A" = 10 A’s, 1 B, 4 A’s).
with_strigars normalizes k-mers across reads by canonical rotation, assigns global letters (A, B, C, …) ordered by frequency, auto-generates colors from a 10-color palette, and computes variable brick widths proportional to motif length.
Key Methods
Data Loading
with_sequences(sequences)
Load sequences — one string per row, ordered top to bottom.
with_names(names)
Load row labels — one name per sequence, rendered on y-axis.
with_template(template: HashMap<char, String>)
Set character-to-color mapping.
with_strigars(strigars)
Load strigar data; switches to strigar mode with auto-generated colors and variable-width bricks.
Alignment
with_x_offset(x_offset: f64)
Apply global x-offset to all rows. Shifts sequences left by x_offset characters.
with_x_offsets(offsets)
Apply independent per-row offsets. Accepts f64 or Option<f64> values.
f64 treated as Some(v); None falls back to global x_offset.
Display
with_values()
Overlay character label inside each brick.
Examples
DNA Repeat Region
RNA Sequence
Protein Secondary Structure
Strigar Tandem Repeats
Per-Row Alignment
Character Display
By default, bricks are solid colored rectangles. Callwith_values() to overlay the character inside each brick (useful for short sequences or when brick size is large enough for legible text).
See Also
- Heatmap — For numeric grids instead of character sequences
- [Multiple sequence alignment tools] — For phylogenetic analysis