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:
Disconnected gene families or decoys ($\Delta L_{\text{KT}} \le 0$). Export separately with subset --component.
1-to-1 residue/codon core spanning the whole component. Ideal backbone for trees & gene-wide $dN/dS$.
1-to-1 homology restricted to one clade (e.g. placental TGFB2 exon or HIV-1 vpu). Extract with --clade.
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:
git clone https://github.com/veg/squint.git && cd squint cargo build --release mkdir -p tutorial_runs
| Format | Flag | Best For | Important Detail |
|---|---|---|---|
| Flat FASTA | -o aligned.fa | IQ-TREE, FastTree, RAxML, HyPhy, AliView | Standard - gaps. Multi-component outputs add component=k to headers. |
| Hierarchical SQLite | --hdb out.hdb | Large genomes, instant slicing, Python scripts | Indexed tables (blocks, tree_nodes, horizon_bubbles, frameshifts). |
| Hierarchical NEXUS | --hnex out.hnex | Archival storage & Web Workbench import | Valid NEXUS (. outside clade vs - indel) + BEGIN HOMOLOGY; block. |
| JSON Ledger | -j ledger.json | Scripting MDL scores, bubbles & posteriors | Full 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):
# 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:
./target/release/squint subset tutorial_runs/cd2.hdb --scale global-core -o tutorial_runs/cd2_core.fa
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:
./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
4. Mode-by-Mode Walkthroughs on Real Data
4.1 Codon Data & Automatic Frameshift Surgery
./target/release/squint docs/examples/kringle_frameshift.fa --mode codon -o tutorial_runs/kringle.fa --hdb tutorial_runs/kringle.hdb
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
./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
4.3 DNA & Coordinate-Indexed Genomic Slicing
./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
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.
./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
Now extract strictly the owning clade with squint subset --clade (empty outgroup columns drop automatically):
# 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
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 - <<'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
-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.
./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:
- Start: Choose a curated preset (or upload FASTA/NEXUS/PHYLIP/
.hnex, paste sequences, or stream directly from NCBI/ENA/GitHub). - Stage 0 (QA): Audit sequence lengths, frames, reverse strands, and the Fixed-Share $M_0$ complexity baseline.
- Stage 1 (Components): Examine disconnected components ($K \ge 1$), MDL gains, repaired frameshifts, and clickable guide-tree clades.
- Stage 2 (Alignment): Pan the color-coded matrix (
GlobalFine,CladeLocalFine,LineagePrivate), toggle universal-core filtering, and inspect every Horizon Bubble interval. - 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
| Goal | Command |
|---|---|
| Flat aligned FASTA (Drop-in MSA) | squint in.fa --mode codon|protein|dna|auto -o out.fa |
| Align + indexed archive + JSON | squint in.fa --mode codon -o out.fa --hdb out.hdb --hnex out.hnex -j out.json |
| Inspect components, clades & bubbles | squint inspect out.hdb |
| Extract universal gap-clean core | squint 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 + clade | squint subset out.hdb --clade N12 -o clade.fa |
| Slice 1-based genomic region | squint subset out.hdb --region SeqID:1-300 -o region.fa |
| Lossless format conversion | squint convert out.hnex -o out.hdb |
| Reconstruct ancestors & bubble profiles | squint ancestors out.hdb -o out.anc.fa --profiles out.anc.tsv [--tree fixed.nwk] |