Sequence Alignment — Biological Sequence Alignment

Research
Introduced by
Saul B. Needleman & Christian D. Wunsch (global); Temple F. Smith & Michael S. Waterman (local)
Year
1970 (global alignment); 1981 (local alignment)
Type
Computational sequence analysis technique
Family
Bioinformatics / omics

What does it do?

Sequence alignment arranges two or more DNA, RNA, or protein sequences so that corresponding positions can be compared.

The arrangement reveals regions of similarity, supports inference of evolutionary relationships, and allows sequencing reads to be mapped to a reference genome. It is a preprocessing step for many genomic workflows, including variant calling, expression quantification, and phylogenetic analysis.

The intuition behind the method

Think of two nearly identical sentences where one has a typo and a missing word. If you line them up letter by letter, you can see where they match, where they differ, and where a gap must be inserted to keep the rest in register. Sequence alignment does this for DNA, RNA, or protein sequences, using a scoring scheme that rewards matches and penalises mismatches and gaps. The algorithm searches for the arrangement with the highest total score, which lets a researcher judge how similar two sequences are and which positions are conserved. The score alone does not establish function; that requires further evidence.

History

Needleman and Wunsch introduced a dynamic programming method for global comparison of protein sequences in 1970. Smith and Waterman extended the approach to local alignment in 1981, which allows conserved regions to be detected within otherwise divergent sequences. As sequence databases grew, heuristic database search tools such as BLAST became among the most widely used tools in biosequence analysis. The arrival of next-generation sequencing in the mid-2000s led to fast short-read aligners such as Bowtie, BWA, HISAT2, and STAR, which map large numbers of reads to reference genomes.

When to use it

Use sequence alignment when you need to compare biological sequences: mapping short reads to a reference genome before variant calling or expression quantification, identifying homologous genes or proteins across species, detecting conserved sequence positions, or preparing aligned input for phylogenetic analysis. Pairwise alignment suits two sequences, and MSA is needed when three or more homologs are compared. Do not treat alignment as an end-point for a quantitative trait or expression question; it is a preprocessing step. Do not apply DNA-oriented settings to protein data without choosing an appropriate substitution matrix. Avoid global alignment when only local similarity is expected, such as when a short domain is compared against a full-length protein.

Limitations and considerations

  • Exact dynamic programming (Needleman–Wunsch, Smith–Waterman) needs O(mn) time and space, which makes whole-genome comparison impractical without heuristic acceleration.
  • The result depends on the substitution matrix and gap penalties, and choosing these settings for a given dataset often requires domain knowledge.
  • For highly divergent sequences with low identity, the alignment may not reflect true homology.
  • Exact multiple sequence alignment is computationally hard for typical scoring schemes. Heuristic MSA tools such as MUSCLE and MAFFT may return solutions that are not globally optimal.
  • In repetitive genomic regions, reads can map to several locations, and multi-mapping reads must be handled explicitly to avoid downstream artifacts.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Dynamic programming (Needleman–Wunsch, Smith–Waterman) returns the optimal alignment for the chosen scoring scheme, so results are reproducible when the matrix and gap penalties are fixed.
  • The same framework applies to nucleotide and amino acid sequences, with the substitution matrix adjusted to the sequence type.
  • Heuristic tools such as BLAST, BWA-MEM, and STAR make comparisons at genome scale practical, at the cost of the optimality guarantee of exact dynamic programming.
  • Standard output formats such as SAM/BAM for reads and the MSA formats written by tools such as ClustalW feed directly into downstream analysis tools.

Applications

  • Mapping RNA-seq short reads to a reference genome or transcriptome as the first step in differential expression analysis.
  • Aligning whole-genome sequencing reads before SNP and indel detection in population genomics or clinical diagnostics.
  • Constructing multiple sequence alignments of orthologous proteins to identify conserved active-site residues across species.
  • Searching sequence databases (GenBank, UniProt) with BLAST to annotate newly assembled genes or proteins by homology.
  • Aligning ChIP-seq or ATAC-seq reads to a reference genome before peak calling to identify protein-binding or open-chromatin regions.
  • Producing aligned sequence matrices as input for maximum-likelihood or Bayesian phylogenetic tree reconstruction.

How it works

How it works

1

One or more query sequences are prepared in FASTA or FASTQ format. Pairwise alignment requires a single reference sequence; multiple sequence alignment (MSA) requires a set of homologous sequences. For short-read data, sequence quality is assessed and, where needed, adapter trimming and quality filtering are applied before alignment.

2

A substitution matrix assigns a score to each aligned pair of characters. BLOSUM62 is used for proteins, and a simple match/mismatch rule is common for nucleotides. A gap scheme, either linear or affine, penalises insertions and deletions. In simplified form, the total score is built from a substitution term for each aligned pair plus a gap term for each gap. In practice, the substitution term is looked up from the matrix rather than being a single constant, and the gap term depends on the gap scheme. The chosen matrix and gap penalties strongly influence which alignment is returned as optimal.

Formula
S(a,b) = match/mismatch + gap\_penalty
3

Dynamic programming fills a scoring matrix whose cells hold the best score for aligning prefixes of the two sequences. Each cell is filled by choosing the best of three moves: aligning the two current characters (adding their substitution score), or introducing a gap in one sequence or the other (paying the gap penalty). The optimal alignment is recovered by tracing back through that matrix. Needleman–Wunsch (1970) performs global alignment across the full length of both sequences. Smith–Waterman (1981) performs local alignment and returns the best-scoring pair of contiguous subsequences. For large-scale mapping, heuristic tools such as BLAST, BWA, HISAT2, and STAR use seed-and-extend strategies, which trade a guarantee of optimality for practical run time.

4

Alignment quality is assessed with percent identity, bit score, E-value for database searches, or alignment coverage. For read mapping, the mapping rate, duplicate rate, and insert-size distribution are inspected. Low-quality or multiply mapping reads are flagged or filtered according to the analysis.

5

The aligned output (SAM/BAM for reads; MSA formats such as those written by ClustalW) is passed to downstream tools. These include SNP and indel calling from read alignments, quantification of gene expression, conserved-domain annotation from protein MSA, and construction of phylogenetic trees.

Common pitfalls

  • Accepting default gap penalties without considering the biology. Affine gap penalties, which charge more to open a gap than to extend one, suit biological insertions and deletions that often span several positions. Default values differ between tools and may not fit your data.
  • Ignoring alignment rate and read-quality metrics. A low mapping rate or a high duplicate rate usually points to a problem with sample preparation or reference choice, and this problem propagates into every downstream step.
  • Treating sequence similarity as evidence of shared function. Two sequences can align well by chance or through convergent evolution, so E-value thresholds and biological context must guide interpretation.
  • Using a short-read aligner such as BWA-MEM on long reads (Oxford Nanopore, PacBio), or the reverse. Read length and error profile call for matched tools, such as minimap2 for long reads.
  • Skipping duplicate marking before variant calling. PCR duplicates inflate apparent variant allele frequencies and should be removed or flagged.

Frequently asked questions

What is the difference between global and local alignment?

Global alignment (Needleman–Wunsch) aligns the full length of both sequences from end to end, inserting gaps wherever necessary. It suits sequences of similar length that are expected to be homologous along their whole extent, such as orthologous full-length proteins. Local alignment (Smith–Waterman) finds the highest-scoring contiguous matching subsequences without requiring end-to-end coverage. It is preferred when a conserved domain must be found within a larger, otherwise divergent sequence, or when query and target lengths differ substantially.

When should I use BLAST versus a short-read aligner like BWA?

BLAST is designed for database similarity search: you have one or a few sequences and want to find homologs in a large database. It returns scored hits ranked by E-value and handles sequences of arbitrary length. Short-read aligners (BWA, Bowtie2, HISAT2) are optimised for mapping very large numbers of short reads from NGS platforms to a reference genome at high throughput. Use BLAST for annotation and homology searches, and a short-read aligner for read mapping in genomics, transcriptomics, or epigenomics.

What is an E-value and what threshold should I use?

The E-value (expect value) reported by BLAST is the number of alignments with an equal or better score that would be expected by chance for one query searched against a database of this size. It therefore grows with database size and query length, so the same score can be more or less significant in different searches. An E-value of 0.001 means that about 0.001 such chance alignments would be expected. Suitable thresholds depend on the database, the query length, and the purpose of the search, so they should be calibrated to the task rather than applied as fixed rules. The bit score is normalised so that it can be compared across searches. Read the E-value together with percent identity and alignment coverage, because a low E-value on a short alignment may still be biologically uninformative.

Does sequence alignment work for long-read sequencing data?

Yes, but standard short-read aligners are not appropriate. Long reads from Oxford Nanopore or PacBio platforms are much longer than Illumina reads and typically carry higher per-base error rates, with a substantial share of the errors being insertions and deletions on some platforms. Long-read mappers such as minimap2 and NGMLR are designed for these data. minimap2 uses minimizer-based seeding and tolerates the elevated indel rates typical of these technologies.

How do I choose a substitution matrix for protein alignment?

The BLOSUM family is the usual default for protein alignment, and BLOSUM62 is the default in BLAST. For more distantly related proteins, a matrix calibrated on more divergent sequences, such as BLOSUM45 or BLOSUM30, is generally used instead. PAM matrices are an older alternative. Match the matrix to the expected divergence between your sequences, and check the choice against the alignments you obtain.

Related methods

Sources

  1. Needleman, S. B., & Wunsch, C. D. (1970). A general method applicable to the search for similarities in the amino acid sequence of two proteins. Journal of Molecular Biology, 48(3), 443–453.

    Open DOI reference
  2. Smith, T. F., & Waterman, M. S. (1981). Identification of common molecular subsequences. Journal of Molecular Biology, 147(1), 195–197.

    Open DOI reference