SQUINT Tutorial & Recipes
GitHub TUTORIAL.md ↗ Repository ↗ ⚡ Open Web Workbench →
Scale-Quotiented Unaligned-Interval Network Transducer

Practical Guide to SQUINT: DNA, Protein, Codons, Clade Blocks & Bubbles

Use SQUINT as a zero-empirical-matrix drop-in replacement for MAFFT, MUSCLE, or PRANK when you want clean flat FASTA alignments — or unlock multi-scale archives (.hnex / .hdb) that keep decoy sequences separate, repair codon frameshifts, isolate clade-specific innovations (CladeLocalFine), and preserve unalignable loops intact as anchored Horizon Bubbles.

1. The 2-Minute Mental Model

Standard aligners squeeze every sequence into a single $N \times L$ rectangle. When cohorts include non-homologous decoys, accessory genes in one clade, or rapidly evolving loops past the homology horizon, forced alignment invents false positional homologies. SQUINT labels every region by the evolutionary scale at which alignment actually compresses the data:

Component (K > 1)

Disconnected gene families or decoys ($\Delta L_{\text{KT}} \le 0$). Export separately with subset --component.

GlobalFine

1-to-1 residue/codon core spanning the whole component. Ideal backbone for trees & gene-wide $dN/dS$.

CladeLocalFine

1-to-1 homology restricted to one clade (e.g. placental TGFB2 exon or HIV-1 vpu). Extract with --clade.

HorizonBubble

Divergent interval pinned between anchors where residue alignment stops, but biophysical grammar is scored & preserved.

2. Setup & Choosing Your Output Formats

Build the native Rust CLI once from the repository root (requires Rust 1.75+ and system libsqlite3), or click any workbench button on this page to run in browser WebAssembly with no install:

shell
git clone https://github.com/veg/squint.git && cd squint
cargo build --release
mkdir -p tutorial_runs
FormatFlagBest ForImportant Detail
Flat FASTA-o aligned.faIQ-TREE, FastTree, RAxML, HyPhy, AliViewStandard - gaps. Multi-component outputs add component=k to headers.
Hierarchical SQLite--hdb out.hdbLarge genomes, instant slicing, Python scriptsIndexed tables (blocks, tree_nodes, horizon_bubbles, frameshifts).
Hierarchical NEXUS--hnex out.hnexArchival storage & Web Workbench importValid NEXUS (. outside clade vs - indel) + BEGIN HOMOLOGY; block.
JSON Ledger-j ledger.jsonScripting MDL scores, bubbles & posteriorsFull serialized CohortHomologyLedger.

3. Replicating Common MSA Tools (Flat Rectangular FASTA)

Need a flat aligned FASTA like MAFFT, MUSCLE, or MACSE? Just specify --mode and -o aligned.fa (add --hdb so you can slice later in milliseconds):

shell • flat FASTA workflows
# Protein alignment (no BLOSUM/LG08 lookup matrices)
./target/release/squint docs/examples/serine_protease_BB12043.faa --mode protein -o tutorial_runs/protease.fa

# Nucleotide alignment
./target/release/squint docs/examples/lentivirus_vpx_vpu.fa --mode dna -o tutorial_runs/lenti.fa

# In-frame Codon alignment + SQLite archive
./target/release/squint docs/examples/cd2_homolog.fa --mode codon -o tutorial_runs/cd2.fa --hdb tutorial_runs/cd2.hdb

Replacing heuristic alignment trimmers (--scale global-core)

Instead of ad-hoc gap-percentage trimming before tree inference, keep strictly the columns with proven universal 1-to-1 homology:

shell
./target/release/squint subset tutorial_runs/cd2.hdb --scale global-core -o tutorial_runs/cd2_core.fa
[squint subset] tutorial_runs/cd2.hdb -> tutorial_runs/cd2_core.fa (seqs=10, components=1, cols=179)

Handling multi-family / decoy cohorts (K > 1)

On mixed_negative_control.fa (15 sequences from 5 families plus reversed ORFs), SQUINT refuses false merges (components=7). Extract any single component cleanly with --component before passing FASTA to downstream tools:

Cross-Kingdom Decoy Cohort: 5 families + 2 reversed ORFs → K = 7 components, 0% false merges.
⚡ Run Decoy Test in Workbench →
shell
./target/release/squint docs/examples/mixed_negative_control.fa --mode codon -o tutorial_runs/mixed.fa --hdb tutorial_runs/mixed.hdb
./target/release/squint subset tutorial_runs/mixed.hdb --component 0 -o tutorial_runs/family0.fa
[squint] N=15 | mode=Codon | time=728.9 ms | L0=17812.0 nats -> L_prov=11063.9 nats (saved +6748.1 nats, 37.9%) | components=7 [squint subset] tutorial_runs/mixed.hdb -> tutorial_runs/family0.fa (seqs=3, components=1, cols=293)

4. Mode-by-Mode Walkthroughs on Real Data

4.1 Codon Data & Automatic Frameshift Surgery

Kringle 1krn + Frameshift: Coagulation factor XII (fa12_human) harbors an empirical +2 nt frameshift.
CD2 Codon → ⚡ Run Kringle Frameshift →
shell
./target/release/squint docs/examples/kringle_frameshift.fa --mode codon -o tutorial_runs/kringle.fa --hdb tutorial_runs/kringle.hdb
[squint] N=5 | mode=Codon | time=21.9 ms | L0=1689.2 nats -> L_prov=1473.2 nats (saved +216.0 nats, 12.8%) | components=1 Component #0 (5 seqs): cols=107 [GlobalFine=85, CladeLocal=0, Private=22] | mean_P_core=0.9317 | horizons=2 | frameshifts=1 -> Repaired Frameshift in 'fa12_human': nt=105 (~codon 35), phase=+2, gain=+102.0 nats

tutorial_runs/kringle.fa is exported frame-restored (107 in-frame codons), ready directly for HyPhy FEL/MEME/BUSTED.

4.2 Protein Data & Condensate Phase Transitions

FUS Condensates & GJD2 Connexin-36: Folded cores anchored while disordered regions & phase shifts trigger Horizon Bubbles.
Vertebrate FUS → ⚡ Run GJD2 Phase Shift →
shell
./target/release/squint docs/examples/fus_vertebrates_18.faa --mode protein -o tutorial_runs/fus.fa --hdb tutorial_runs/fus.hdb -j tutorial_runs/fus.json
./target/release/squint docs/examples/tetrapod_gjd2_phase_transition.faa --mode protein --hdb tutorial_runs/gjd2.hdb
# GJD2 summary: [squint] N=18 | mode=Protein | time=130.7 ms | L0=17034.7 nats -> L_prov=1792.7 nats (saved +15242.0 nats, 89.5%) | components=1 Component #0 (18 seqs): cols=335 [GlobalFine=291, CladeLocal=44, Private=0] | mean_P_core=0.9973 | horizons=2 | frameshifts=0 -> Coarse Horizon Bubble (step #17): 10x8 clades, 4 vs 19 local cols | class=Special(GPC) | Macro-PRIME=-24.39 nats | dHydro=+0.76 | dCharge=+0.20

4.3 DNA & Coordinate-Indexed Genomic Slicing

Primate Lentivirus (HIV-1 vpu vs HIV-2/SIV vpx): Zero cross-gene collision between accessory ORFs.
⚡ Run 6-Taxon Locus → Instant 22-Genome Atlas →
shell
./target/release/squint docs/examples/lentivirus_vpx_vpu.fa --mode dna -o tutorial_runs/lenti.fa --hdb tutorial_runs/lenti.hdb
./target/release/squint subset tutorial_runs/lenti.hdb --region AB253421.1_vpu_Human_immunodefici:1-300 -o tutorial_runs/lenti_vpu_1_300.fa
[squint] N=6 | mode=Dna | time=560.3 ms | L0=13728.4 nats -> L_prov=9611.8 nats (saved +4116.6 nats, 30.0%) | components=1 Component #0 (6 seqs): cols=3053 [GlobalFine=857, CladeLocal=1734, Private=462] | mean_P_core=0.8949 | horizons=18 [squint subset] tutorial_runs/lenti.hdb -> tutorial_runs/lenti_vpu_1_300.fa (seqs=6, components=1, cols=453)

5. What to Do With Clade-Restricted Regions (CladeLocalFine)

When a domain or accessory gene exists only inside one clade (such as the 25-aa placental innovation in TGFB2 or HIV-1 vpu vs. HIV-2 vpx), testing selection on an outgroup-padded alignment injects non-homologous gap columns. The clean workflow is: (1) identify the owning clade in .hdb, then (2) subset to that clade.

Tetrapod TGFB2 Pro-Domain: Placental clade N12 carries a 25-aa CladeLocalFine block (mean_P = 0.986).
⚡ Inspect TGFB2 in Workbench →
shell + python3 (stdlib sqlite3)
./target/release/squint docs/examples/tetrapod_tgfb2_prodomain.faa --mode protein --hdb tutorial_runs/tgfb2.hdb

python3 - <<'PY'
import sqlite3
conn = sqlite3.connect("tutorial_runs/tgfb2.hdb")
nodes = {r[0]: r for r in conn.execute(
    "SELECT node_id, is_leaf, label, left_node_id, right_node_id FROM tree_nodes WHERE comp_id=0"
)}
def leaves(nid):
    _, is_leaf, lbl, l, r = nodes[nid]
    return [lbl] if is_leaf else leaves(l) + leaves(r)

for bid, cs, cl, owner, pcsv in conn.execute(
    "SELECT block_id, col_start, col_len, owner_node_id, fine_posteriors_csv "
    "FROM blocks WHERE comp_id=0 AND scale='CladeLocalFine' AND col_len >= 5 ORDER BY col_start"
):
    p = [float(x) for x in pcsv.split(",") if x]
    taxa = leaves(owner)
    print(f"block={bid} cols={cs}..{cs+cl-1} len={cl} clade={nodes[owner][2]} ntax={len(taxa)} mean_P={sum(p)/len(p):.3f}")
    print("  taxa:", ", ".join(taxa))
PY
block=17 cols=178..202 len=25 clade=N12 ntax=8 mean_P=0.986 taxa: Mus_musculus__Rodentia, Bos_taurus__Ungulata, Pteropus_vampyrus__Chiroptera, Canis_lupus__Carnivora, Loxodonta_africana__Afrotheria, Equus_caballus__Perissodactyla, Tursiops_truncatus__Cetacea, Homo_sapiens__Primates

Now extract strictly the owning clade with squint subset --clade (empty outgroup columns drop automatically):

shell
# 8 placental mammals (retains GlobalFine core + 25-aa placental block)
./target/release/squint subset tutorial_runs/tgfb2.hdb --clade N12 -o tutorial_runs/tgfb2_placental.fa

# Separate HIV-1 vpu (N3) and HIV-2/SIV vpx (N0) clades from lentivirus cohort
./target/release/squint subset tutorial_runs/lenti.hdb --clade N3 -o tutorial_runs/lenti_vpu_clade.fa
./target/release/squint subset tutorial_runs/lenti.hdb --clade N0 -o tutorial_runs/lenti_vpx_clade.fa
[squint subset] tutorial_runs/tgfb2.hdb -> tutorial_runs/tgfb2_placental.fa (seqs=8, components=1, cols=442) [squint subset] tutorial_runs/lenti.hdb -> tutorial_runs/lenti_vpu_clade.fa (seqs=4, components=1, cols=2037) [squint subset] tutorial_runs/lenti.hdb -> tutorial_runs/lenti_vpx_clade.fa (seqs=2, components=1, cols=1873)

6. What to Do With Anchored Horizon Bubbles (HorizonBubbleReport)

Inside a Horizon Bubble, 1-to-1 column correspondence has dissolved ($P_{\text{fine}} \le 0.50$), so SQUINT avoids hallucinating gaps and instead stores exact unaligned local_seq_idx:start:len intervals anchored inside the merge step (token_step = 3 for codon, 1 for protein/DNA). Use Python's built-in sqlite3 to extract intact bubble subsequences for composition, charge, disorder, glycosylation sequon, or protein language model analysis:

python3 • extract intact Horizon Bubbles to FASTA & CSV
python3 - <<'PY'
import csv, sqlite3

conn = sqlite3.connect("tutorial_runs/gjd2.hdb")
step = 3 if dict(conn.execute("SELECT key, val FROM meta"))["mode"] == "codon" else 1
seqs = {(c, i): (n, r) for c, i, n, r in conn.execute(
    "SELECT comp_id, local_seq_idx, name, raw_seq FROM sequences"
)}

rows = []
with open("tutorial_runs/gjd2_bubble0.fa", "w") as fa:
    for cid, bidx, bcls, gain, liv, riv in conn.execute(
        "SELECT comp_id, bubble_idx, dominant_biophys_class, macro_biophys_gain_nats, "
        "left_intervals_str, right_intervals_str FROM horizon_bubbles WHERE comp_id=0 AND bubble_idx=0"
    ):
        for side, ivs in [("left", liv), ("right", riv)]:
            for tok in (x for x in ivs.split(",") if x):
                loc, st, ln = (int(v) for v in tok.split(":"))
                name, raw = seqs[(cid, loc)]
                sub = raw[st * step : (st + ln) * step]
                fa.write(f">{name}|bubble={bidx}|side={side}|pos={st+1}..{st+ln}|class={bcls}\n{sub}\n")
                gpc = sum(c in "GPC" for c in sub) / max(1, len(sub))
                chg = sum(c in "KR" for c in sub) - sum(c in "DE" for c in sub)
                rows.append((side, name, len(sub) // step, round(gpc, 3), chg, bcls, round(gain, 2)))

with open("tutorial_runs/gjd2_bubbles.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["side", "taxon", "token_len", "gpc_frac", "net_charge", "dom_class", "macro_prime_nats"])
    w.writerows(rows)

for r in rows[:2] + rows[10:12]:
    print(r)
PY
('left', 'Gallus_gallus__Aves', 4, 0.0, -1, 'Special(GPC)', -24.39) ('left', 'Struthio_camelus__Aves', 4, 0.0, -1, 'Special(GPC)', -24.39) ('right', 'Homo_sapiens__Primates', 19, 0.737, -1, 'Special(GPC)', -24.39) ('right', 'Mus_musculus__Rodentia', 19, 0.632, -1, 'Special(GPC)', -24.39)
JSON Option: Passing -j ledger.json stores the exact same intervals in components[c]["horizon_bubbles"] alongside unaligned_seqs — useful in notebooks or JavaScript/R pipelines without SQLite.

Scale-Aware Ancestral Sequences & Profiles (squint ancestors)

SQUINT carries hierarchy boundaries directly into marginal Inside–Outside ancestral state reconstruction: positional GlobalFine and CladeLocalFine cores use empirical Bayes posteriors (4-rate Γ under JTT/K2P or the 61-state codon generator with ML branch lengths & ω, plus optional --tree fixed.nwk), ancestors outside a clade-restricted module abstain with - rather than fabricating homology, and unaligned Horizon Bubbles report non-positional length, hydropathy, net charge, and dominant biophysical class profiles across splits.

Bash — CLI ancestral reconstruction (inline or from archive)
./target/release/squint docs/examples/cd2_homolog.fa --mode codon \
  --ancestors --anc-fasta tutorial_runs/cd2.anc.fa --anc-profiles tutorial_runs/cd2.anc.tsv

./target/release/squint ancestors tutorial_runs/cd2.hdb \
  -o tutorial_runs/cd2.anc.fa --profiles tutorial_runs/cd2.anc.tsv --tree fixed.nwk

7. Using the Browser WebAssembly Workbench

Every workflow in this tutorial is also interactive at https://veg.github.io/squint/ — all alignment computation runs client-side inside a dedicated Web Worker:

  1. Start: Choose a curated preset (or upload FASTA/NEXUS/PHYLIP/.hnex, paste sequences, or stream directly from NCBI/ENA/GitHub).
  2. Stage 0 (QA): Audit sequence lengths, frames, reverse strands, and the Fixed-Share $M_0$ complexity baseline.
  3. Stage 1 (Components): Examine disconnected components ($K \ge 1$), MDL gains, repaired frameshifts, and clickable guide-tree clades.
  4. Stage 2 (Alignment): Pan the color-coded matrix (GlobalFine, CladeLocalFine, LineagePrivate), toggle universal-core filtering, and inspect every Horizon Bubble interval.
  5. Stage 3 (Dossier): Run the in-browser Surgical Subsetter (by component, clade node, taxon list, or coordinate window), launch Scale-Aware Ancestral Sequences & Profiles (MAP sequences, uncertain site posteriors, and Horizon Bubble biophysical profiles), and export .anc.fa, .state.tsv, .hnex, JSON, or standalone HTML dossiers.

8. Command Cheat Sheet

GoalCommand
Flat aligned FASTA (Drop-in MSA)squint in.fa --mode codon|protein|dna|auto -o out.fa
Align + indexed archive + JSONsquint in.fa --mode codon -o out.fa --hdb out.hdb --hnex out.hnex -j out.json
Inspect components, clades & bubblessquint inspect out.hdb
Extract universal gap-clean coresquint subset out.hdb --scale global-core -o core.fa
Isolate one component ($K>1$)squint subset out.hdb --component 0 -o comp0.fa
Extract clade-restricted block + cladesquint subset out.hdb --clade N12 -o clade.fa
Slice 1-based genomic regionsquint subset out.hdb --region SeqID:1-300 -o region.fa
Lossless format conversionsquint convert out.hnex -o out.hdb
Reconstruct ancestors & bubble profilessquint ancestors out.hdb -o out.anc.fa --profiles out.anc.tsv [--tree fixed.nwk]