Sequence analysis
Pairwise sequence alignment
Compare two sequences directly, preserve the aligned strings and scoring settings, and separate correspondence from similarity scores.
Pairwise alignment workflows
Choose the workflow that matches your sequence type and comparison question. Each preserves its own aligned strings or score matrices without treating them as interchangeable.
Pairwise sequence alignment
Align a two-record FASTA with MAFFT and compare the same pair with a Needleman–Wunsch global score from StringZilla.
Open workflowPairwise protein alignment
Generate a two-protein MAFFT G-INS-i alignment alongside independent StringZilla Needleman–Wunsch global and Smith–Waterman local score matrices.
Open workflowPairwise DNA alignment
Generate a two-DNA-sequence MAFFT alignment alongside independent StringZilla Needleman–Wunsch global and Smith–Waterman local score matrices.
Open workflowWhat is pairwise sequence alignment?
Pairwise sequence alignment is the process of arranging exactly two biological sequences so that positions proposed to correspond appear in the same columns. Identical residues or nucleotides appear as matches, different characters appear as substitutions, and inserted gaps represent possible insertion or deletion events. The resulting alignment is a hypothesis about positional correspondence between the sequences, not a direct measurement of function or evolutionary history.
A pairwise alignment algorithm uses a scoring system to choose among many possible arrangements. Global alignment compares the sequences across their complete lengths, while local alignment finds the strongest matching region within them. Needleman–Wunsch is the classic global alignment algorithm, and Smith–Waterman is the classic local alignment algorithm. Both use dynamic programming to find an optimal result under the specified scoring model.
Use pairwise sequence alignment when you already have two sequences and want to:
- compare a protein variant with its reference sequence;
- align two homologous proteins or domains;
- compare two alleles, amplicons, transcripts, or DNA constructs;
- locate substitutions, insertions, and deletions;
- map corresponding positions between two sequences;
- measure identity across a defined alignment;
- inspect whether two sequences share one strongly conserved region.
The alignment is only as meaningful as the question, inputs, and settings behind it. Two unrelated sequences can always be arranged somehow, and a numerically optimal alignment is not necessarily a biologically valid one.
Which pairwise alignment should you use?
Choose the alignment scope before choosing a particular sequence alignment tool.
| Your question | Recommended approach | Best suited for | Main limitation |
|---|---|---|---|
| Should these two complete sequences correspond from beginning to end? | Global sequence alignment | Full-length homologs, alleles, isoforms with similar architecture, and engineered constructs | Unrelated terminal regions or extra domains can distort the result |
| What is the strongest shared region between these sequences? | Local sequence alignment | Conserved domains, motifs, fragments, and partial homology | Ignores weaker or unrelated regions outside the best local match |
| Does a fragment overlap one end of a longer sequence? | Overlap or end-gap-aware alignment | Amplicons, reads, trimmed constructs, and partial sequences | End-gap treatment differs among tools and must be reported |
| Which database sequences resemble my query? | BLAST or another similarity search | Discovering possible homologs in a database | A heuristic search is not the same calculation as an exact pairwise alignment |
| How do three or more homologous sequences correspond? | Multiple sequence alignment | Protein families, conserved motifs, profiles, and phylogenetic preparation | The problem and algorithm differ from aligning only two sequences |
| Do weakly similar proteins share the same fold? | Structure-based sequence alignment | Proteins whose structural correspondence is clearer than their sequence similarity | Requires compatible experimental or predicted structures |
A global alignment is usually appropriate when both sequences represent comparable full-length molecules. A local alignment is safer when only one domain, motif, or subsequence is expected to correspond. Using global alignment merely because the input contains two sequences can force unrelated flanks into an apparently orderly but misleading result.
How to align two sequences online
A reliable online sequence alignment should begin with a scientific choice, not simply with pasting two strings into a form.
- Confirm the molecule type. Determine whether both inputs are proteins, DNA, or RNA. Do not align a nucleotide sequence directly against an amino-acid sequence.
- Prepare exactly two records. Preserve stable identifiers and remove accidental spaces, position numbers, unsupported symbols, or copied formatting.
- Choose global or local alignment. Compare complete lengths globally, or search for the best shared region locally.
- Select an appropriate scoring model. Protein alignments normally require an amino-acid substitution matrix. DNA alignments may use a nucleotide matrix or explicit match and mismatch scores.
- Record the gap settings. Gap-opening, gap-extension, and terminal-gap behavior can change both the alignment and its score.
- Inspect the aligned sequences. Review the actual matches, substitutions, gaps, coverage, and important biological positions rather than relying on one summary number.
- Save the method and settings. The same raw sequences can produce different results under another algorithm or parameter set.
A two-record FASTA input looks like this:
>reference_protein
MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ
>variant_protein
MKTAYIAKQRTISFVKSHFSRQLDERLGLIEVQFASTA headers should be unique. The sequence lines should contain only symbols supported for the selected molecule type. Ambiguous amino acids or nucleotides may be accepted by some tools, but the tool-specific treatment of those symbols should remain visible in the result.
Pairwise protein sequence alignment
Pairwise protein sequence alignment compares two amino-acid sequences. It is useful when you need to align two proteins, compare an engineered protein with its parent, inspect amino-acid substitutions, or map corresponding residues between known or suspected homologs.
Unlike a simple character match, a protein alignment can give different scores to different substitutions. Replacing leucine with isoleucine may be treated more favorably than replacing leucine with aspartate because the first pair has more similar physicochemical and evolutionary behavior. Protein alignment tools represent these preferences through substitution matrices such as BLOSUM or PAM. BLOSUM matrices were derived from conserved blocks in related protein families.
There is no universally correct matrix for every protein pair. Matrix choice, gap penalties, sequence length, domain architecture, and expected evolutionary distance all affect the result. Use the same settings when comparing scores between several protein pairs, and preserve the matrix name with every reported alignment.
Pairwise protein alignment is especially useful for:
- Variant comparison. Locate substitutions, insertions, deletions, or altered termini between a reference and a mutant protein.
- Ortholog or paralog comparison. Examine conserved positions and divergent regions between two related proteins.
- Construct verification. Compare a designed sequence with the intended parent and confirm tags, linkers, deletions, or engineered mutations.
- Domain comparison. Align two corresponding domains without allowing unrelated regions elsewhere in the proteins to control the result.
- Residue mapping. Translate a position from one protein sequence to its aligned position in another.
If two proteins have different domain architectures, an end-to-end alignment may be the wrong model. Align the shared domain locally or compare the relevant subsequences directly. For broader guidance covering protein families and alignments of more than two records, see protein sequence alignment.
Pairwise DNA sequence alignment
Pairwise DNA sequence alignment arranges two nucleotide sequences to reveal exact base matches, substitutions, insertions, deletions, and unaligned ends. A DNA alignment tool is appropriate for comparing two alleles, amplicons, plasmid constructs, coding sequences, transcripts, or homologous genomic regions.
Before aligning two DNA sequences, check their orientation. A sequence and the reverse complement of its homolog can appear unrelated if both are submitted in their original direction. Some alignment software can test orientation automatically, while other tools require you to reverse-complement one sequence first. MAFFT provides direction-adjustment modes for nucleotide alignments, but orientation handling depends on the selected implementation and settings.
Important DNA-specific decisions include:
- Orientation. Confirm that both records represent the same strand direction.
- Ambiguous bases. Record how symbols such as
N,R, orYare interpreted. - Coding versus genomic sequence. Genomic DNA and mature messenger RNA may differ by entire introns and normally require a spliced-alignment method rather than a generic pairwise aligner.
- Complete versus partial sequence. Use global alignment for comparable full-length constructs and local or overlap alignment for fragments.
- Whole-genome scale. Long assemblies, rearrangements, and synteny require a dedicated whole-genome alignment workflow.
- Protein-coding interpretation. A nucleotide alignment identifies base-level changes, while translating and aligning the proteins answers a different question about amino-acid conservation.
For a workflow configured specifically for nucleotide input, use DNA sequence alignment.
How is a sequence alignment score calculated?
A sequence alignment score is the total value assigned to one proposed alignment under a defined scoring system. It normally combines scores for aligned character pairs with penalties or negative scores for gaps.
Conceptually:
alignment score =
sum of match or substitution scores
+ sum of gap-opening scores
+ sum of gap-extension scoresWith a common affine gap model, the score or penalty for a gap of length k depends on one gap-opening term plus k - 1 gap-extension terms:
gap score(k) = gap open + (k - 1) × gap extensionThe exact sign convention differs among tools: one program may display positive penalties that are subtracted, while another may expose negative gap scores that are added. EMBOSS Needle, for example, reports the comparison matrix, gap-opening penalty, gap-extension penalty, aligned length, identity, similarity, gaps, and final score together.
| Score component | What it represents | Effect of changing it |
|---|---|---|
| Match score | Reward for aligning identical residues or bases | A larger reward favors alignments containing more exact matches |
| Substitution or mismatch score | Value assigned to non-identical aligned characters | Protein matrices distinguish conservative from unfavorable substitutions |
| Gap-open score | Cost of starting an insertion or deletion | A stronger penalty tends to produce fewer separate gaps |
| Gap-extension score | Additional cost for lengthening an existing gap | A weaker extension penalty favors fewer, longer gaps over many short gaps |
| Terminal-gap treatment | Whether unaligned sequence ends are penalized | Can strongly affect fragments, tags, incomplete sequences, and unequal lengths |
A raw sequence alignment score has meaning only in its original context. Do not directly compare scores produced with:
- different algorithms;
- different substitution matrices;
- different gap settings;
- global versus local alignment;
- different sequence lengths;
- protein versus nucleotide scoring;
- different treatments of terminal gaps or ambiguous symbols.
A longer pair of similar sequences will often produce a larger raw score than a shorter pair, even when the shorter pair has a higher percentage identity. BLAST bit scores and E-values apply statistical normalization to local search results, but not every pairwise alignment program reports those statistics.
How to interpret identity, similarity, coverage, and gaps
A pairwise alignment should be interpreted as a collection of related measurements rather than one definitive percentage.
| Metric | Meaning | Common interpretation error |
|---|---|---|
| Aligned length | Number of columns in the reported alignment | Assuming it equals both original sequence lengths |
| Exact matches | Columns containing the same residue or nucleotide | Ignoring whether the match covers a meaningful part of each sequence |
| Percent identity | Exact matches divided by a stated denominator | Reporting the percentage without saying which denominator was used |
| Protein similarity | Exact or matrix-favored amino-acid pairs | Treating it as a molecule-independent quantity |
| Query coverage | Fraction of the first sequence included in the aligned region | Confusing high local identity with full-length correspondence |
| Target coverage | Fraction of the second sequence included in the aligned region | Reporting only query coverage when the second sequence is much longer |
| Gaps | Alignment columns containing an insertion or deletion character | Assuming every gap corresponds to one known historical mutation event |
| Raw score | Objective optimized by the selected method | Comparing scores from different settings or programs |
Percent identity
Percent identity is usually calculated as:
percent identity = exact matches / stated denominator × 100The denominator may be the complete alignment length, the number of non-gap aligned columns, the query length, the target length, or another explicitly defined value. EMBOSS Needle reports identity over the aligned region using its reported alignment length, including gap-containing columns in that length.
For reproducibility, report the numerator and denominator as well as the percentage—for example, 31/33 identical aligned positions (93.9%).
Protein similarity
Protein similarity includes amino-acid pairs that receive a favorable value in the selected substitution matrix. It is therefore matrix-dependent. Two protein sequences can have the same percent identity but different similarity scores because their non-identical residues differ in how conservatively they substitute.
For DNA, “similarity” is sometimes used loosely as a synonym for identity. State the exact score or matrix definition instead of assuming that the term has one universal meaning.
Coverage
Identity without coverage can be misleading. Two 500-residue proteins may share a 40-residue domain with 90% local identity while the remaining 460 residues do not align. That result answers a different question from 90% identity across both complete proteins.
Report coverage separately for each sequence when their lengths differ.
Homology
Homology means descent from a common ancestor. It is not a percentage. Sequences may be homologous or not homologous; they are not “80% homologous.” Sequence identity, similarity, alignment length, statistical significance, structural correspondence, and biological context provide evidence used to infer homology.
Worked example: compare two protein sequences
Consider these two aligned amino-acid sequences:
reference MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ
variant MKTAYIAKQRTISFVKSHFSRQLDERLGLIEVQ
||||||||||.||||||||||||.|||||||||The sequences have:
- 33 aligned positions;
- 31 exact matches;
- two substitutions;
- no gaps;
- 93.9% identity when calculated as
31 / 33 × 100.
The first substitution is Q → T, while the second is E → D. A protein substitution matrix may score E → D more favorably because both residues are acidic, so matrix-based similarity may be higher than exact identity.
The alignment score still cannot be determined from the displayed strings alone. It also requires the substitution matrix or match/mismatch values and the selected gap model.
Even a 93.9% identity result does not establish that the proteins have identical activity. A substitution at an active site, binding interface, cleavage site, localization signal, or structurally constrained position may matter more than many conserved residues elsewhere. Always inspect biologically important positions directly.
Pairwise alignment versus BLAST and multiple sequence alignment
Several tools can display two sequences in aligned rows, but they do not necessarily perform the same calculation.
| Method | Typical result | Best use | Important distinction |
|---|---|---|---|
| Needleman–Wunsch | Optimal global alignment and score under one scoring model | Two complete sequences expected to correspond end to end | Evaluates the full lengths of both sequences |
| Smith–Waterman | Optimal local alignment and score under one scoring model | Best shared domain, motif, or subsequence | Can leave unrelated flanks outside the alignment |
| BLAST with query and subject sequences | One or more heuristic local alignments with statistical measures | Fast local comparison and significance assessment | BLAST is heuristic and is not guaranteed to return the exact dynamic-programming optimum |
| MAFFT with two records | Two aligned sequences produced by the selected MAFFT strategy | Convenient protein or nucleotide alignment with configurable modes | MAFFT is a multiple-sequence alignment program; preserve the actual strategy and settings |
| Clustal Omega with two records | A two-row alignment produced by a progressive MSA system | Compatibility with Clustal workflows and downstream formats | It should not automatically be described as an exact Needleman–Wunsch calculation |
| Multiple sequence alignment | Alignment of three or more homologous sequences | Families, conserved columns, profiles, and phylogenetics | Additional sequences change the optimization problem and may alter column placement |
Can Clustal Omega align two sequences?
Yes. Clustal Omega can accept two sequences and return an aligned output, so “Clustal pairwise alignment” is a reasonable description of the resulting two-row file. However, Clustal Omega is designed as a multiple sequence alignment program. Its progressive and profile-based methods should not be confused with a dedicated exact pairwise dynamic-programming implementation.
Use Clustal Omega when you need its formats or expect to expand the analysis to more sequences. Use a dedicated global or local pairwise method when the exact score and algorithmic definition are central to the question.
Is pairwise alignment the same as a sequence search?
No. Pairwise alignment directly compares two supplied sequences. A sequence-search tool compares a query with many database records and ranks possible matches. NCBI’s BLAST two-sequence mode allows a query and subject to be compared directly, but it still uses BLAST’s heuristic local-search behavior.
Common mistakes when comparing two sequences
Choosing global alignment for sequences that share only one region
A global method must account for both complete lengths. If one sequence contains an extra domain, long tag, signal peptide, or unrelated flank, the alignment may contain many gaps and weakly supported correspondences. Use local alignment or isolate the shared domain.
Using local identity as though it described both complete sequences
A short local alignment can have very high identity while covering only a small fraction of each input. Always report aligned length and coverage.
Comparing DNA sequences in opposite orientations
A reverse-complemented homolog can appear unrelated to the original strand. Confirm DNA orientation before interpreting a poor alignment.
Comparing the wrong sequence boundaries
Isoforms, precursor proteins, mature chains, transit peptides, tags, and incomplete records can produce terminal differences that are artifacts of sequence selection rather than biological divergence.
Treating every alignment score as comparable
A raw score from one matrix or gap model cannot be ranked directly against a score produced with another configuration. Preserve the complete scoring definition.
Reporting “percent homology”
Report percent identity or a clearly defined similarity metric. Homology is an evolutionary inference, not a continuous percentage.
Ignoring low-complexity or repetitive regions
Repeats may support several alignments with similar scores. The top-scoring path can look precise even when the positional correspondence is ambiguous.
Using generic pairwise alignment for a specialized problem
Genomic DNA versus messenger RNA requires spliced alignment. Complete genomes require genome-scale methods. Very weak protein similarity may require profile or structure-based comparison. Choose the method that represents the biological problem rather than forcing every comparison into the same two-sequence tool.
What should an online sequence alignment tool return?
Useful online sequence alignment software should make the result inspectable and reproducible. At minimum, retain:
- the original sequence identifiers and unaligned inputs;
- the aligned sequences with inserted gaps;
- the algorithm and software version;
- global, local, overlap, or other alignment scope;
- the protein matrix or nucleotide scoring model;
- gap-opening, gap-extension, and terminal-gap settings;
- the raw alignment score and its definition;
- identity as both a count and percentage;
- the identity denominator;
- aligned length and coverage for both sequences;
- the number and distribution of gaps;
- warnings, rejected symbols, or failed records;
- downloadable alignment and result files.
Do not accept an unlabeled “sequence match” percentage as a complete result. Without the alignment scope, denominator, score definition, and input coverage, the number may answer a different question from the one you intended to ask.
The featured ProteinIQ workflow below keeps two forms of evidence separate: MAFFT returns the aligned sequence strings, while StringZilla v5 independently calculates a Needleman–Wunsch global score. The score and alignment are related, but they are not interchangeable outputs.
How pairwise sequence alignment works
MAFFT returns aligned sequences while StringZilla independently returns a Needleman–Wunsch global score; the workflow keeps those outputs distinct.
- Define scope. Decide whether the full sequences or only a shared region should be compared.
- Prepare the pair. Verify molecule type, orientation, headers, boundaries, and ambiguous symbols.
- Set scoring. Record the substitution and gap settings rather than relying on an unlabeled score.
- Run comparison. Generate aligned strings and, when useful, an independent pairwise score.
- Interpret and export. Inspect identity, coverage, gaps, terminal effects, and biologically important positions.
Inputs and outputs
Check formats before running, then inspect and download the result from every workflow step.
Inputs
Alignment input
FASTAPDBmmCIFTwo protein, DNA, or RNA sequences in FASTA format.
Outputs
Alignment outputs
FASTACSVTSVPDBJSONAligned FASTA plus method-native score tables and downloadable settings.
Tools for pairwise sequence alignment
Use these methods to prepare inputs, run the core analysis, inspect outputs, and validate the evidence described in this workflow.

MAFFT
Create configurable protein, DNA, or RNA alignments

StringZilla v5
Calculate pairwise global, local, or edit-distance score matrices

Clustal Omega
Create scalable protein or nucleotide multiple-sequence alignments

MUSCLE5
Generate conventional or ensemble multiple-sequence alignments

HMMER
Find homologs with profile hidden Markov models

MMseqs2
Search and cluster large protein or nucleotide sequence sets

USAlign
Align macromolecular structures and derive residue correspondence

FoldSeek
Find and compare structurally similar proteins

PDB to FASTA converter
Extract sequences from structures before comparison

FastTree
Estimate trees from large sequence alignments

IQ-TREE
Infer maximum-likelihood phylogenies from alignments

RAxML-NG
Run maximum-likelihood phylogenetic analysis
Other sequence analysis workflows
Compare related approaches based on the molecular system, available evidence, required inputs, and decision you need to support.
Frequently asked questions
Two protein, DNA, or RNA sequences in FASTA format.
Aligned FASTA plus method-native score tables and downloadable settings.
Start from the scientific scope: global or local, pairwise or multiple, sequence or structure, and conventional or genome scale. Then record the method, substitution model, gap settings, sequence type, and any filtering rather than relying on defaults without provenance.
No. Scores and identities quantify similarity under a defined model. Homology is an evolutionary interpretation, and shared function requires additional evidence such as domain context, conserved residues, structure, phylogeny, experiments, or curated annotation.
Preserve both raw sequences, algorithm, substitution and gap settings, aligned strings, and score definition.
A complete pairwise sequence alignment project is usually quote-based because providers scope sequence curation, method selection, alignment review, interpretation, and downstream analysis together. Harvard’s FY26 bioinformatics core first defines deliverables and a time estimate, then charges $180–$265 per hour; MSU lists $84–$110 per hour and expects at least eight consultant hours for custom analysis.
The total depends on sequence count and length, input cleanup, molecular type, the number of methods compared, manual review, genome scale, figures, phylogenetic or structural follow-up, and whether the deliverable includes interpretation or only alignment files.
ProteinIQ self-service starts at $29 per month for academic Plus and $99 per month for commercial Pro, with the configured pairwise sequence alignment run estimated in credits before submission. Done-for-you analysis is scoped separately and can include data preparation, method comparison, interpretation, and a reproducible handoff.
Start with a workflow you can inspect and edit
Add your inputs, review the settings, and keep every structure, score, table, and file connected to the step that produced it.