Sequence Alignment Fundamentals

Two DNA sequences look almost identical, but one letter is missing near the middle. Is that a real deletion, or an artifact of how you lined them up? This question sits underneath nearly every computational task in modern genomics. It asks how to line up two strings of A, C, G, T (or amino acids). The goal is to maximize true biological similarity. Sequencing machines do not read whole chromosomes. Instead, they produce millions of short fragments that must be placed back onto a reference. Every comparison of "how similar is gene X in species A to gene X in species B" requires an alignment first. Without that alignment, the comparison means nothing. Sequence alignment matters because similarity is the raw signal from which biology infers homology — shared ancestry. Homology, in turn, is the basis for inferring function, evolutionary history, and disease-causing variation. A single misplaced gap in an alignment can flip a synonymous change into a frameshift. It can also hide a real mutation behind an artificial mismatch. Getting alignment right is not a bookkeeping detail. It is the inferential bridge between raw sequence data and every downstream biological claim. That includes claims from "this bacterium is antibiotic-resistant" to "these two genes descended from a common ancestor." The big picture is that alignment is an optimization problem. Given a scoring scheme that rewards matches and penalizes mismatches and gaps, find the best arrangement. The goal is the arrangement of the two sequences that maximizes total score. Doing this by eye is impossible beyond a few dozen bases. Doing it by brute-force comparison of all possible alignments is also impossible. That brute-force limit hits beyond a few hundred bases. The breakthrough was reframing alignment as a problem solvable by dynamic programming. Later, as sequencing became massive, fast heuristic search methods emerged. These include BLAST, and read-mapping tools like BWA and Bowtie. They approximate the optimal alignment without paying its full computational cost. This article builds alignment from first principles. It covers what a pairwise alignment is, and how scoring matrices and gap penalties encode biological assumptions. It explains how dynamic programming guarantees an optimal answer for two sequences. It also explains how heuristic seed-and-extend methods make the problem tractable at genome scale. These methods are the logic behind BLAST and short-read mappers. It closes with worked numerical examples and the real algorithmic history. That history includes Needleman-Wunsch, Smith-Waterman, and the statistical framework of Karlin and Altschul. That framework made BLAST scores interpretable.

Key takeaways
  • Alignment lines up two sequences to maximize a score built from match/mismatch rewards and gap penalties, revealing likely homology.
  • Global alignment (Needleman-Wunsch) compares full-length sequences end to end; local alignment (Smith-Waterman) finds the best-matching subregion.
  • Scoring matrices (e.g., PAM, BLOSUM for proteins; simple match/mismatch for DNA) encode how "costly" a substitution is biologically.
  • Affine gap penalties (a gap-open cost plus a smaller gap-extend cost) reflect that one long indel is more likely than many separate short ones.
  • Dynamic programming guarantees the mathematically optimal alignment but scales as (sequence length)²; genome-scale data need heuristics.
  • BLAST and short-read mappers (BWA, Bowtie) use seed-and-extend or FM-index/suffix-array search to align millions of reads fast, trading guaranteed optimality for speed.
The core insight

Sequence alignment finds the highest-scoring way to superimpose two sequences under an explicit, biologically motivated scoring system — everything downstream (assembly, annotation, variant calling, phylogenetics) inherits whatever choices that scoring system makes.

The core idea

A pairwise alignment is an arrangement of two sequences, one above the other, so that biologically corresponding positions line up in columns, with gaps (dashes, "indels") inserted where one sequence has an insertion or the other a deletion relative to their common ancestor. Each column is either a match (identical residues), a mismatch (a substitution), or a gap (an insertion/deletion event, indicated by a dash opposite a real residue). The goal of alignment is to choose gap placements and column correspondences that maximize a numerical score, computed by summing a reward or penalty for every column according to a scoring scheme. Two distinct alignment problems recur throughout genomics. Global alignment forces the entire length of both sequences into the comparison, appropriate when the two sequences are of similar length and presumed to be homologous over their whole extent (e.g., comparing two orthologous genes). Local alignment instead finds the highest-scoring matching subregion, ignoring flanking sequence that doesn't align well — appropriate when only part of a sequence is conserved (a shared domain inside otherwise unrelated proteins, or a short sequencing read that matches one small stretch of a genome). Confusing these two modes is a classic error: forcing a short read into a global alignment against an entire chromosome, or forcing two full-length divergent proteins into local alignment, gives biologically misleading results. The scoring scheme has three components that must all be specified before "best alignment" has any meaning: a substitution score for every possible pair of aligned residues (identity scores for DNA are often simple, e.g. +1 for a match and −1 for a mismatch, but protein alignments use empirically derived matrices like BLOSUM or PAM); a gap-open penalty, the cost of starting a new gap; and a gap-extend penalty, the (usually smaller) cost of lengthening an existing gap by one more position. This last piece — the affine gap penalty — encodes a real biological prior: a single deletion event of length 5 is far more probable than five independent single-base deletion events, so the scoring scheme should not penalize a 5-base gap five times as harshly as a 1-base gap.

Mechanism

Step 1 — Choosing the scoring matrix. For nucleotides the simplest scheme uses a flat match/mismatch score (e.g., match = +2, mismatch = −1), sometimes refined to weight transitions (purine↔purine or pyrimidine↔pyrimidine substitutions) as less costly than transversions, since transitions occur more frequently in evolution. For proteins, substitution cost must reflect chemistry and evolutionary observation: replacing leucine with isoleucine (both hydrophobic, similar size) is usually near-neutral, while replacing leucine with proline (which kinks the backbone) is often deleterious. PAM matrices (Dayhoff, 1978) are built by counting observed substitutions in very closely related protein alignments and extrapolating outward using a Markov model; BLOSUM matrices (Henikoff & Henikoff, 1992) are built directly from observed substitution frequencies in blocks of ungapped, moderately to highly divergent real protein alignments (BLOSUM62 — built from blocks with ≥62% identity — is the default for most protein searches).

Step 2 — Setting gap penalties. A gap-open penalty (e.g., −10) is charged once when a gap begins; a smaller gap-extend penalty (e.g., −1) is charged for each additional gap position. This affine model makes long single indels cheaper, per base, than many scattered short ones, matching the biology of how insertions/deletions actually arise (replication slippage, unequal crossing-over, transposon activity typically create one contiguous indel, not many separate single-base ones).

Step 3 — Filling the dynamic programming matrix. Place one sequence along the top of a grid and the other down the side. Build a matrix F where F(i,j) is the best score for aligning the first i residues of sequence 1 with the first j residues of sequence 2. Each cell is filled from three possible sources — a diagonal move (align residue i with residue j, score = match/mismatch), a move from the left (gap in sequence 2), or a move from above (gap in sequence 1) — always taking the maximum (or, for edit-distance formulations, the minimum): F(i,j) = max{ F(i−1,j−1) + s(xᵢ,yⱼ), F(i−1,j) − gap, F(i,j−1) − gap } For global alignment (Needleman-Wunsch, 1970), the first row and column are initialized with cumulative gap penalties (forcing the alignment to start at the sequences' true beginnings), and the final answer is read from the bottom-right corner, after which a traceback step walks backward through the matrix following which of the three moves produced each cell's value, reconstructing the actual alignment. For local alignment (Smith-Waterman, 1981), cells are never allowed to go below zero — any cell that would score negative is reset to 0, meaning the alignment can restart anywhere — and the traceback begins at whichever cell in the entire matrix holds the maximum score, stopping when it hits a zero. This single change (the zero-floor) is what converts a global aligner into a local one; it lets the algorithm find a strong match embedded anywhere in two otherwise unrelated sequences.

Step 4 — Complexity, and the move to heuristics. Both algorithms are exact and guaranteed optimal, but they require filling a matrix of size (length1 + 1) × (length2 + 1), i.e., O(n·m) time and memory. Aligning two 100-base sequences (10,000 cells) is instantaneous; aligning a 150-base sequencing read against a 3.2-billion-base human genome directly would require filling roughly 4.8 × 10¹¹ cells — computationally prohibitive to do naively for even one read, let alone the hundreds of millions of reads a modern sequencing run produces.

Step 5 — Seed-and-extend heuristics (BLAST logic). BLAST (Basic Local Alignment Search Tool, Altschul et al., 1990) sidesteps full dynamic programming by first finding short, exact or near-exact matches called seeds (words of length ~11 for DNA, ~3–4 for protein, chosen so that true homologs are very likely to share at least one such word), using a precomputed hash table/index of all words in the database for instant lookup. Only positions that produce a seed hit are then examined further: the alignment is extended outward from the seed in both directions, accumulating score, and extension stops when the score drops too far below the best score seen so far (the X-drop criterion) — at which point a full Smith-Waterman-style optimization is applied only to that small local region. This confines expensive dynamic programming to a tiny, pre-filtered set of candidate regions, making database-scale search practical, at the cost of a small chance of missing very weak but real alignments that happen to share no seed word.

Step 6 — Indexed exact-match search (BWA/Bowtie logic for NGS reads). Short-read mappers exploit the fact that most sequencing reads are highly similar to the reference (typically >95% identity for human resequencing) and that a reference genome, unlike a growing sequence database, is fixed and can be indexed once. Tools such as BWA and Bowtie build a compressed, full-text index of the entire reference genome using the Burrows-Wheeler Transform (BWT) combined with an FM-index, a data structure that allows searching for any substring of the genome in time roughly proportional to the length of the query, independent of genome size, and using memory far smaller than the raw genome sequence. The read is matched (allowing a small, tunable number of mismatches and gaps) directly against this index; when perfect exact matching fails, the algorithm backtracks to try alternative bases at low-quality positions, effectively performing a bounded search over nearby sequences rather than a full dynamic-programming scan. This is why a modern aligner can place a 150-base-pair read onto the human genome in a fraction of a millisecond, whereas naive Smith-Waterman against the whole genome would not.

Figure
Global vs. local alignment: same two sequences, different question
Global alignment (Needleman-Wunsch) G C A T G C U G - A T T A C A whole length forced into alignment; every base accounted for Local alignment (Smith-Waterman) xxAAT CGTA GGxxx yyAAT CGTA CCyyy only the best-scoring subregion (blue/red) is reported; flanks ignored high-scoring matched core Use global for full-length homologs of similar size; local for domains, reads, or partial matches.
Figure
Dynamic programming matrix: filling and traceback
Needleman-Wunsch matrix for GATTACA vs GACTACA (schematic) - G A C T A C A - G A T T A C A traceback path = optimal alignment each cell F(i,j) = max(diagonal+match/mismatch, up−gap, left−gap) Score fills bottom-right cell first; traceback (red arrow, run backward) reconstructs the alignment. O(n·m) time/memory — fine for two genes, impossible for read-vs-genome without heuristics.

The evidence

Needleman and Wunsch (1970) did not merely propose a scoring idea; they proved that a recursive, matrix-filling procedure could find the mathematically optimal global alignment between two sequences without exhaustively enumerating every possible alignment (which grows combinatorially with sequence length). Their original paper aligned short protein sequences and showed that the dynamic programming recursion — computing each cell from only three neighboring cells — guarantees the same answer as exhaustive search while requiring only O(n·m) operations. This was the founding result that made computational sequence comparison a rigorous, tractable problem rather than a matter of expert eyeballing, and it established the general dynamic-programming paradigm later reused across bioinformatics (RNA secondary structure prediction, multiple sequence alignment, hidden Markov model decoding all borrow the identical recursive logic).

Smith and Waterman (1981) proved the complementary result: by modifying the recursion so that scores are never allowed below zero, and by starting traceback from the single highest-scoring cell anywhere in the matrix rather than forcing the alignment through both sequences' full length, the same dynamic-programming machinery finds the optimal local alignment — the single best-matching subsequence pair — even when the sequences are mostly unrelated. This mattered enormously in practice: real biological sequences are full of unrelated flanking regions, unrelated domains fused onto a conserved core, and sequencing artifacts at read ends, so forcing a global alignment routinely produces a misleading, diluted score. Smith-Waterman remains the gold-standard exact algorithm against which every heuristic aligner is benchmarked for sensitivity.

Karlin and Altschul (1990), together with the original BLAST paper (Altschul, Gish, Miller, Myers, and Lipman, 1990), supplied the piece that made heuristic search statistically trustworthy rather than merely fast: a theory (based on extreme-value statistics) for the expected distribution of alignment scores between random, unrelated sequences of given length and composition. This let BLAST report an E-value — the expected number of alignments with a score at least as good as the observed one, that would occur by chance alone in a database of a given size — turning a raw alignment score into a statistically interpretable statement about whether a match is likely to reflect true homology or coincidence. Benchmarking studies through the 1990s (comparing BLAST hits against structurally confirmed protein homologs, and against exhaustive Smith-Waterman results) repeatedly showed that BLAST recovers the great majority of true homologs found by exhaustive search, at a small fraction of the computational cost, validating the seed-and-extend heuristic as a practical substitute for exact dynamic programming at database scale.

Li and Durbin (2009), in developing BWA, and Langmead and colleagues (2009), in developing Bowtie, demonstrated empirically that Burrows-Wheeler/FM-index-based exact-match search, combined with a bounded mismatch/backtracking search, could map tens of millions of short reads from a next-generation sequencing run to the human genome in minutes to hours on ordinary hardware — a task that would have been utterly infeasible with a Smith-Waterman-style full dynamic-programming scan against each of 3.2 billion reference positions. Their papers benchmarked mapping accuracy and speed directly against simulated reads with known true origin, showing the indexed approach recovers the correct mapping location for the overwhelming majority of reads within realistic error and mismatch tolerances, which is why BWA/Bowtie-family tools became (and remain) the standard first step in nearly every resequencing, exome, RNA-seq, and ChIP-seq pipeline.

Worked examples

Example 1 — Filling a small Needleman-Wunsch matrix by hand. Align sequence X = `GATTACA` against sequence Y = `GACTACA` using match = +1, mismatch = −1, linear gap = −2. Both sequences are length 7. Set up an 8×8 matrix (including the leading gap row/column). Initialize row 0 and column 0 with cumulative gap penalties: F(0,j) = −2j, F(i,0) = −2i. Filling proceeds left to right, top to bottom. At the position comparing X₃ = T (index 3) against Y₃ = C (index 3), the residues mismatch, so the diagonal contribution is F(2,2) − 1. Because X and Y differ at exactly one position (T vs C at the 4th letter) and are otherwise identical letter-for-letter with no length difference, the optimal global alignment has no gaps at all: ``` G A T T A C A G A C T A C A ``` This gives 6 matches (+6) and 1 mismatch (−1) for a total score of +5 — better than any alignment that introduces gaps, because a gap-open penalty of −2 immediately outweighs the benefit of converting one mismatch into two matches elsewhere. This illustrates a general point: when sequences are the same length and mostly identical, the optimum is usually the ungapped, position-by-position alignment; gaps only pay off when they remove a run of several mismatches or correct a genuine length difference.

Example 2 — A gap that should exist: length mismatch. Now align X = `GATTACA` (7 bases) against Z = `GATACA` (6 bases, missing the second T). Position-by-position (no gap) alignment would be: ``` G A T T A C A G A T A C A - ``` Comparing column by column without a gap: G-G match, A-A match, T-T match, T-A mismatch, A-C mismatch, C-A mismatch, A-(-) — this accumulates 3 matches and 3 mismatches and an end gap, score = 3(+1) + 3(−1) + gap penalty ≈ 0 − 2 = −2 (using gap-open −2, ignoring extend since it's one base). Instead, inserting a single gap at the position of the missing T: ``` G A T T A C A G A - T A C A ``` Now every column matches except the single gap column: 6 matches (+6) and one gap (−2, gap-open only, length 1), for a score of +4 — decisively better than −2. This demonstrates the central purpose of gaps: a single well-placed indel correctly models a true deletion event and yields a far higher score than forcing a substitution-only alignment, exactly the biological scenario (one lost nucleotide) the algorithm is meant to detect. It also shows why the traceback, not just the final score, matters: two alignments with very different biological interpretations (indel vs. three substitutions) are compared purely numerically, and the scoring scheme decides which is preferred.

Common misconceptions & traps

MisconceptionWhy it's wrong
"The highest-scoring alignment is always the biologically 'true' one."The scoring scheme encodes assumptions (equal transition/transversion cost, fixed gap penalties); a different reasonable scheme can yield a different optimal alignment. Score optimality is mathematical, not automatically biological truth.
"More gaps always means a worse alignment."A single well-placed gap can dramatically improve the score by removing many downstream mismatches (Example 2); the issue is gap placement and number, not gaps per se.
"Global and local alignment give the same answer, just different names."They answer different questions: global forces full-length correspondence and can be badly misled by unrelated flanking sequence; local ignores flanks and reports only the best matching core. Using the wrong one for the data (e.g., globally aligning a short read to a whole chromosome) gives nonsense.
"BLAST/BWA always find the mathematically optimal alignment."These are heuristics that trade guaranteed optimality for speed; they can miss very weak true homologies (BLAST, if no seed word is shared) or return a slightly suboptimal placement (short-read mappers, under strict mismatch/time budgets). Exact Smith-Waterman remains the gold standard for sensitivity, at much higher cost.
"A low percent identity always means no shared ancestry."Distant but real homologs can share well under 20% identity at the sequence level while retaining clearly homologous 3-D structure and function; percent identity alone, without proper statistical scoring (E-values), is a poor homology detector at high divergence.

The scientist behind it

Saul Kohn (later Saul B. Needleman) and Christian Wunsch published their algorithm in 1970 while working on protein sequence comparison, at a time when the handful of known protein sequences were being compared essentially by hand or with primitive computer scoring. Their innovation was recognizing that the alignment problem, despite an astronomically large number of possible alignments for even modest sequence lengths, has optimal substructure: the best alignment of two full sequences can be built up from the best alignments of their prefixes, which is exactly the condition dynamic programming exploits. Temple Smith and Michael Waterman, working independently over a decade later, recognized that a small modification (the zero floor) converted this global machinery into a tool for finding locally conserved regions — a far more common biological scenario, since most real sequence comparisons involve partial similarity (a shared domain, a partly conserved regulatory region) rather than end-to-end identity. Samuel Karlin and Stephen Altschul then supplied the statistical theory that let raw scores be converted into rigorous probabilities, and Altschul's subsequent collaboration with David Lipman, Warren Gish, Webb Miller, and Eugene Myers produced BLAST, arguably the single most-used piece of bioinformatics software ever written, run informally billions of times by researchers worldwide.

Origins · 1 minSaul B. Needleman & Christian D. Wunsch and how this was discovered
SB
Saul B. Needleman & Christian D. Wunsch
collaboration published 1970 · molecular biology / early computational biology, University of California

Needleman and Wunsch introduced the first dynamic-programming algorithm for optimal global sequence alignment, establishing that pairwise alignment could be solved exactly and efficiently rather than by exhaustive or ad hoc comparison, a result that became the mathematical foundation for essentially all subsequent alignment and search algorithms in genomics.

History
- 1970 — Needleman and Wunsch publish the first dynamic-programming algorithm for optimal global sequence alignment.
- 1978 — Margaret Dayhoff and colleagues publish the PAM (Point Accepted Mutation) protein substitution matrices.
- 1981 — Smith and Waterman publish the local-alignment variant, finding optimal matching subregions.
- 1990 — Karlin and Altschul publish the statistical theory of local alignment scores; Altschul, Gish, Miller, Myers, and Lipman publish BLAST.
- 1992 — Steven and Jorja Henikoff publish the BLOSUM substitution matrices from observed protein block alignments.
- 2009 — Li and Durbin (BWA) and Langmead et al. (Bowtie) publish Burrows-Wheeler/FM-index-based short-read aligners for next-generation sequencing data.

Where this matters today

Every clinical genome or exome sequencing pipeline begins with read mapping: raw reads from an Illumina or long-read platform are aligned to a reference genome (typically GRCh38 for humans) using BWA-MEM, Bowtie2, or minimap2 (for long reads), and every downstream step — variant calling for inherited disease diagnosis, tumor mutation profiling in oncology, detecting drug-resistance mutations in HIV or Mycobacterium tuberculosis — depends entirely on those reads being placed correctly. A misaligned read near an indel-rich region is a classic source of false-positive variant calls, which is why modern pipelines add a local realignment step around candidate indels specifically to correct alignment artifacts introduced by simple gap-penalty heuristics. In agricultural and conservation genomics, BLAST-style homology search identifies disease-resistance genes across crop cultivars and wild relatives, and alignment of environmental DNA reads against reference databases underlies metagenomic species identification for biodiversity monitoring and pathogen surveillance (including the rapid genomic tracking of viral outbreaks such as SARS-CoV-2, where aligning patient-derived sequences to a reference is the first step in lineage and mutation tracking). Multiple sequence alignment, the natural extension of pairwise alignment to more than two sequences, underlies Comparative Genomics analyses that identify conserved regulatory elements and estimate evolutionary divergence times, while the same dynamic-programming logic, extended and adapted, is central to Genome Assembly (deciding which overlapping reads truly derive from the same genomic locus) and to Genome Annotation (aligning candidate transcripts or known protein domains against a newly assembled genome to identify genes).

Ask the tutor: How would changing the gap-open penalty in a read aligner affect variant calling accuracy near insertions and deletions?

Why do protein alignments use matrices like BLOSUM or PAM instead of simple match/mismatch scores?

Amino acid substitutions are not biologically equivalent: replacing one hydrophobic residue with another similar one (e.g., leucine for isoleucine) is often functionally tolerated and observed frequently in real evolved proteins, while replacing a residue with a chemically very different one (e.g., glycine for tryptophan) is far more disruptive and rarer in nature. BLOSUM and PAM matrices are built by tabulating how often each substitution is actually observed across large sets of real, evolutionarily related protein alignments, so the score for each amino acid pair reflects empirical evolutionary tolerance rather than a simplistic identical/non-identical distinction. Using a matrix rather than flat scoring lets alignment algorithms correctly favor biologically plausible substitutions over implausible ones, improving sensitivity for detecting true, distant homologs.

What is the practical difference between BLAST and a short-read mapper like BWA?

BLAST is designed to search a query sequence (often a single gene or protein) against a large, heterogeneous database, tolerating substantial divergence and reporting statistically scored local alignments; it is optimized for sensitivity across evolutionary distances. BWA (and similar short-read mappers) is designed for the opposite scenario: many millions of short, highly similar reads (typically >95% identical to the reference) need to be placed onto one specific, fixed reference genome as fast as possible. BWA exploits this fixed-reference, high-similarity setting with a precomputed Burrows-Wheeler/FM-index of the genome, allowing near-instant substring lookup, whereas BLAST's seed-and-extend approach is built for flexible, divergent cross-database search rather than raw throughput against one genome.

Can dynamic programming alignment ever be "wrong" even though it's mathematically optimal?

Yes — "optimal" is only optimal with respect to the chosen scoring scheme, not with respect to biological truth. If the gap penalties or substitution matrix poorly reflect real evolutionary probabilities for the sequences in question, the mathematically best-scoring alignment can still misplace a true indel or favor an implausible run of substitutions over a more biologically likely gap. This is why parameter choice (which matrix, which gap penalties) is itself a biological decision, and why alignments of highly divergent or repeat-rich sequences are sometimes ambiguous or scoring-scheme-dependent even when the algorithm has found the certifiably optimal answer under its own rules.

Why does aligning a short read near an indel sometimes produce spurious mismatches instead of a gap?

Standard gap penalties compete against the mismatch penalty; if a genuine one-base deletion falls near the end of a read, or if quality scores are low, a heuristic aligner may find it "cheaper" under its scoring parameters to report a cluster of substitutions rather than the single correct indel, especially with a stringent gap-open penalty. This is a well-known source of local misalignment around true insertion/deletion variants, which is why variant-calling pipelines typically add a local realignment step (re-running a more careful, indel-aware alignment specifically in windows flagged as gap-prone) before calling small insertions and deletions, correcting exactly this class of artifact.

How does alignment relate to genome assembly and annotation?

Genome assembly uses the same underlying comparison logic — detecting overlaps between reads — to determine which reads originate from the same genomic region and stitch them into longer contiguous sequences, before a reference even exists; alignment against an existing reference, by contrast, assumes the reference is already known. Genome annotation then relies heavily on alignment in the opposite direction: candidate transcripts, known protein domains, or homologous genes from other species are aligned against a newly assembled genome to identify likely gene locations, exon-intron boundaries, and conserved functional elements. In both cases, the same core concepts — scoring, gaps, and the global/local distinction — reappear, just applied to different comparison targets.

Is a higher percent identity always evidence of closer evolutionary relationship?

Not necessarily by itself — percent identity must be considered together with alignment length and statistical significance, since a very short alignment (a few residues) can show high percent identity purely by chance, while a long, biologically meaningful alignment across a whole conserved domain might show comparatively modest identity yet be far more statistically and evolutionarily convincing. This is exactly the failure mode E-values are designed to catch: two sequences can be 100% identical over just 6 residues by pure chance in a large database, while a genuine, deeply conserved 300-residue domain alignment at 35% identity represents overwhelming evidence of shared ancestry. Percent identity alone, divorced from alignment length and expected-by-chance statistics, is not a reliable homology measure.

Why does gap placement matter so much for interpreting a coding sequence alignment?

A gap of length divisible by three, placed within a coding region, preserves the reading frame and corresponds to a clean insertion or deletion of whole codons (often less disruptive to protein function); a gap of any other length shifts the reading frame downstream of the gap, changing every subsequent codon and usually producing a nonfunctional truncated protein. An alignment algorithm using generic DNA-level scoring has no inherent knowledge of codon structure, so gap placement chosen purely to maximize a nucleotide-level score can, in a coding region, land at a position that is numerically optimal but implies a biologically implausible frameshift; this is why coding-sequence alignments are often performed at the protein or codon level specifically to respect reading frame.

Before this

Where this leads