Skip to content

Article image
Sequence Alignment: Pairwise Comparison of Biological Sequences

May 16, 2026 · Updated: May 25, 2026

Overview

Sequence alignment is the fundamental operation of bioinformatics, placing two or more biological sequences side by side to identify regions of similarity that may reflect functional, structural, or evolutionary relationships. Pairwise alignment compares exactly two sequences and forms the basis for database searching, primer design, and phylogenetic inference. The alignment problem is solved by dynamic programming algorithms, Needleman-Wunsch for global alignment and Smith-Waterman for local alignment, that find the optimal scoring path through a matrix of match, mismatch, and gap penalties.

Key Concepts

Alignments are classified as global or local. Global alignment forces alignment across the entire length of both sequences and is most appropriate for closely related sequences of similar length. Local alignment identifies short, conserved regions and is ideal for detecting shared domains between divergent sequences. Substitution matrices such as BLOSUM62 and PAM250 provide log-odds scores for every possible amino acid replacement, while DNA alignments typically use simple match/mismatch scores. Gap penalties, often a combination of a gap-opening and a gap-extension penalty, discourage excessive insertions or deletions. Heuristic tools like BLAST trade guaranteed optimality for speed by seeding alignments with exact word matches.

Applications

Pairwise alignment is used daily in molecular biology. It underpins polymerase chain reaction primer design by checking primer-template complementarity, validates DNA sequencing results by aligning reads to reference genomes, and identifies conserved residues in protein structure prediction. Comparative genomics relies on alignment to detect horizontal gene transfer in bacterial genetics, and restriction site mapping uses alignment to predict restriction enzyme digestion patterns.

Practical Protocol

For pairwise global alignment using EMBOSS Needle, prepare two sequences in FASTA format: needle seq1.fasta seq2.fasta -gapopen 10 -gapextend 0.5 -outfile needle_output.txt. The gap open penalty (10 for proteins, 10–15 for nucleotides) penalizes introduction of a new gap, while the gap extension penalty (0.5 for proteins, 0.5–1.0 for nucleotides) penalizes extending an existing gap. Higher gap opening penalties produce fewer, longer gaps; lower penalties allow many short gaps. For local alignment with EMBOSS Water: water seq1.fasta seq2.fasta -gapopen 10 -gapextend 0.5 -outfile water_output.txt. Water finds the region of highest similarity between two sequences, ideal for detecting conserved domains in otherwise divergent sequences. The output includes the alignment with match/mismatch symbols (| for identical, : for conservative, . for semi-conservative, space for non-conservative), alignment scores, and percent identity. Choose substitution matrices wisely: BLOSUM62 is the default for most protein alignments and is suitable for sequences sharing 30–70% identity. BLOSUM80 works better for closely related sequences (>80% identity), while BLOSUM45 is more sensitive for distant relationships (<30% identity). For DNA alignment, use the EDNAFULL matrix with match=1, mismatch=0 for closely related sequences, or match=1, mismatch=-1 with higher gap penalties for cross-species comparisons. Adjust parameters iteratively: if the alignment is not biologically meaningful (e.g., aligning unrelated regions), increase gap penalties. Use the seaweeds JVM or the Galaxy web platform for running EMBOSS tools without command-line access. For batch pairwise alignments, use the needlem. or waterm (multiple) variants with a sequence file of query sequences against a single target.


resource: Lab Lexicon Sequence Aligner