- Alignment identity, similarity, coverage, and gaps are fundamental measures used to evaluate biological sequence alignments and interpret relationships between DNA, RNA, and protein sequences. These measures help researchers determine how closely two sequences match, how much of each sequence has been aligned, and where insertions, deletions, or substitutions have occurred. They are widely used in sequence comparison, homology detection, genome annotation, evolutionary analysis, protein characterization, and database searches such as BLAST.
- Sequence alignment arranges two or more biological sequences so that corresponding nucleotides or amino acids can be compared. An alignment may contain identical residues, chemically or evolutionarily similar residues, mismatches, and gaps. Each of these features provides different biological information. Therefore, alignment identity, similarity, coverage, and gaps should be considered together rather than relying on a single numerical score.
- Sequence identity refers to the percentage of aligned positions containing exactly the same nucleotide or amino acid in the compared sequences. For DNA and RNA, an identical position contains the same nucleotide in both sequences. For proteins, an identical position contains the same amino acid residue. Identity is commonly calculated by dividing the number of identical aligned positions by the total number of positions included in the alignment and multiplying by 100.
- The general formula is:
[
\text{Percentage Identity} =
\frac{\text{Number of Identical Positions}}
{\text{Total Alignment Positions Included}}
\times 100
]
- For example, if two aligned sequences contain 100 positions and 85 positions have identical residues, their percentage identity is 85%. However, the denominator must be defined carefully. Some programs include gap-containing columns in the alignment length, while other calculations exclude certain gap positions. Consequently, identity values from different tools or analysis settings may not always be directly comparable.
- Sequence similarity is related to identity but is particularly important in protein sequence analysis. Similarity includes identical amino acids as well as non-identical amino acids that have comparable biochemical or physicochemical properties. For example, leucine and isoleucine are different amino acids, but both are hydrophobic and have similar structural characteristics. Such substitutions may receive positive scores in protein substitution matrices such as BLOSUM and PAM.
- Protein similarity is generally evaluated using substitution matrices rather than simply counting chemically similar amino acids. These matrices assign scores to amino acid substitutions according to observed or modelled evolutionary substitution patterns. A positive substitution score indicates that a particular residue pair is relatively favourable under the matrix model, while a negative score indicates a less favourable substitution. Similarity is therefore dependent on the selected scoring matrix and the rules used to classify positive-scoring substitutions.
- A simplified similarity percentage can be calculated as:
[
\text{Percentage Similarity} =
\frac{\text{Identical Positions + Similar Substitutions}}
{\text{Total Positions Considered}}
\times 100
]
- This simplified calculation is not a universal standard. In many alignment programs, similarity is reported as a count or percentage of positive-scoring residue pairs. The result depends on the substitution matrix and the program’s reporting convention. DNA alignments generally focus on nucleotide identity and alignment scores because nucleotide substitutions are not usually classified by biochemical similarity in the same way as amino acid substitutions.
- Sequence coverage describes how much of a query sequence or target sequence is represented in an alignment. It is particularly important when interpreting database search results. A high percentage identity across a short region may indicate a strong local match, but it does not necessarily mean that the complete sequences are closely related. Coverage helps distinguish short conserved regions from extensive sequence-level correspondence.
- Query coverage is the percentage of the query sequence included in the alignment. It is commonly calculated as:
[
\text{Query Coverage} =
\frac{\text{Number of Query Residues or Bases Covered}}
{\text{Total Query Length}}
\times 100
]
- For example, if a query protein contains 400 amino acids and 300 residues are included in the alignment, query coverage is 75%. Target coverage is calculated in the same way using the target sequence length. Query and target coverage may differ because the two sequences can have different lengths and the alignment may cover only part of either sequence.
- Coverage is especially important in local alignment searches. A short conserved domain may produce high identity but low query coverage. Conversely, a long alignment may cover most of the query while containing a moderate percentage of identical residues. Both results can be biologically meaningful, but they support different interpretations. High identity and high coverage often provide stronger evidence of extensive sequence correspondence than high identity over a very short region.
- Gaps are spaces introduced into an alignment to represent possible evolutionary insertions or deletions, collectively known as indels. A gap may indicate that one sequence has an insertion relative to another, that the other sequence has experienced a deletion, or that an evolutionary event has produced a length difference between corresponding regions. However, an alignment gap does not independently establish the exact historical mutation event or its direction.
- Gaps are represented by hyphens in many alignment formats. For example:
Sequence 1: ATGCTAGCT
Sequence 2: ATG-TAGCT
- The gap in the second sequence allows the remaining nucleotides to be aligned with the corresponding positions in the first sequence. In this example, the alignment contains eight nucleotide-to-nucleotide columns and one gap-containing column.
- Gaps are important because they affect alignment length, identity calculations, coverage, and alignment scores. An alignment with many gaps may indicate substantial length differences, repetitive regions, poorly conserved regions, or uncertainty in the alignment. However, gaps can also be biologically meaningful and may represent genuine insertions or deletions that occurred during evolution.
- Alignment algorithms use gap penalties to prevent the introduction of excessive gaps. A gap-opening penalty is applied when a new gap is introduced, while a gap-extension penalty is applied when an existing gap is extended. Affine gap penalties commonly use the expression:
[
G(k)=g_o+(k-1)g_e
]
- where (G(k)) is the cost of a gap of length (k), (g_o) is the gap-opening cost, and (g_e) is the gap-extension cost. This convention charges the opening cost for the first gap position and extension costs for subsequent positions. Some software uses a different convention, so the scoring definition should be checked before comparing results.
- The number and distribution of gaps can also be summarized using gap statistics. Gap count may refer to the number of separate gap runs, whereas gap length refers to the number of alignment columns occupied by gaps. These are different measurements. For example, three separate gaps of one position each represent three gap runs and three gap positions, while one continuous gap of three positions represents one gap run and three gap positions.
- A gap percentage can be calculated by dividing the number of gap-containing alignment columns by the total alignment length:
[
\text{Gap Percentage} =
\frac{\text{Number of Gap-Containing Columns}}
{\text{Total Alignment Length}}
\times 100
]
- This measure should be interpreted carefully because an alignment column containing gaps in both sequences, if permitted by a particular representation, and columns containing a gap in only one sequence may be handled differently by different software. For ordinary pairwise alignments, gap-containing columns generally represent positions where at least one sequence has a gap.
- Identity, similarity, coverage, and gaps are closely related but measure different properties. Identity measures exact residue matches, similarity evaluates conservative substitutions as well as exact matches, coverage measures the fraction of a sequence represented in the alignment, and gaps describe positions introduced to account for sequence-length differences. A complete interpretation should consider all four measures together with alignment score, sequence length, biological context, and statistical significance.
- For example, consider two protein sequences that produce an alignment with 90% identity but only 15% query coverage. This may indicate a highly conserved short domain rather than extensive similarity across the full proteins. Another alignment may show 45% identity and 95% query coverage, suggesting broader sequence correspondence despite a lower exact-match percentage. Neither result should be interpreted without examining the aligned region and the biological functions of the sequences.
- Alignment scores provide another important measure of alignment quality. They are calculated using match rewards, mismatch penalties, substitution matrices, and gap penalties. A higher score generally indicates a more favourable alignment under the selected scoring system, but raw scores from different scoring systems are not necessarily comparable. For database searches, BLAST also reports statistical measures such as the bit score and E-value. The bit score is a normalized alignment score, while the E-value estimates the number of alignments with an equivalent or better score expected by chance in a database search of a particular size. A low E-value supports statistical significance, but it does not by itself prove biological function or evolutionary relationship.
- Identity and similarity are commonly used in comparative genomics and proteomics. In genome analysis, nucleotide identity helps identify conserved regions, homologous genes, and sequence variants. In protein analysis, similarity can reveal relationships between proteins that have accumulated amino acid substitutions during evolution. Coverage helps determine whether a match represents a complete protein, a conserved domain, or a short sequence fragment. Gap patterns can provide information about insertions, deletions, domain boundaries, and evolutionary changes.
- These measurements are also important in functional annotation. A protein sequence that aligns with a characterized protein over most of its length and has substantial identity or similarity may provide useful evidence for functional prediction. However, functional transfer should consider conserved domains, catalytic residues, protein architecture, sequence coverage, and experimental evidence. Similarity alone does not guarantee identical biological function, particularly when proteins belong to large families with related but distinct activities.
- In phylogenetic and evolutionary studies, sequence identity and similarity can help describe sequence conservation and divergence. Insertions and deletions may also provide useful evolutionary characters. However, evolutionary distance cannot be estimated reliably from raw percentage identity alone in every situation. Multiple substitutions at the same position, differences in evolutionary rates, alignment uncertainty, and sequence composition can influence observed identity. Appropriate evolutionary models and carefully constructed multiple sequence alignments are often required for phylogenetic analysis.
- Several bioinformatics tools provide alignment statistics. BLAST reports alignment length, identity, gaps, query coverage, bit score, and E-value in commonly used output formats. FASTA-based search tools provide related alignment statistics. Pairwise alignment tools such as EMBOSS Needle and Water report alignment scores and residue-level comparisons. Multiple sequence alignment programs such as MAFFT, MUSCLE, and Clustal Omega produce alignments that can be examined for conserved positions, substitutions, and gaps. Biopython provides functions for calculating alignment properties and processing alignment results programmatically.
- The following Python example uses Biopython to calculate identity, gap-containing columns, and a simple coverage estimate from an already aligned pair of sequences. It assumes that both aligned sequences have equal lengths and that the alignment uses hyphens to represent gaps.
from Bio.Align import MultipleSeqAlignment
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
seq1 = “ATGCTAGCT”
seq2 = “ATG-TAGCT”
if len(seq1) != len(seq2):
raise ValueError(“Aligned sequences must have equal lengths.”)
alignment_length = len(seq1)
identical_positions = 0
gap_columns = 0
comparable_positions = 0
for a, b in zip(seq1, seq2):
if a == “-” or b == “-“:
gap_columns += 1
continue
comparable_positions += 1
if a.upper() == b.upper():
identical_positions += 1
identity_including_gap_columns = (
identical_positions / alignment_length * 100
)
identity_excluding_gap_columns = (
identical_positions / comparable_positions * 100
if comparable_positions else 0
)
gap_percentage = gap_columns / alignment_length * 100
coverage_seq1 = sum(base != “-” for base in seq1) / len(seq1.replace(“-“, “”)) * 100
coverage_seq2 = sum(base != “-” for base in seq2) / len(seq2.replace(“-“, “”)) * 100
print(“Alignment length:”, alignment_length)
print(“Identical positions:”, identical_positions)
print(“Identity including gap columns:”, identity_including_gap_columns)
print(“Identity excluding gap columns:”, identity_excluding_gap_columns)
print(“Gap-containing columns:”, gap_columns)
print(“Gap percentage:”, gap_percentage)
print(“Sequence 1 coverage:”, coverage_seq1)
print(“Sequence 2 coverage:”, coverage_seq2)
- For this example, the two sequences contain one gap-containing alignment column. The example demonstrates how denominator choices affect identity calculations. The coverage expressions shown here are not useful for determining the fraction of an original, unaligned sequence covered by an alignment because the original sequence lengths are not retained separately. In practical analyses, query and target coverage should be calculated using the original sequence lengths and the aligned coordinates.
- The following example illustrates how BLAST tabular output can be used to retrieve commonly reported alignment statistics. The selected fields include query and subject identifiers, percentage identity, alignment length, mismatch count, gap count, alignment coordinates, E-value, bit score, and query coverage.
blastp \
-query query.fasta \
-db protein_database \
-out blast_results.tsv \
-outfmt “6 qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore qcovs”
- The pident field reports percentage identity, length gives alignment length, gapopen reports the number of gap openings, and qcovs reports query coverage per subject across the HSPs, according to the selected BLAST output definition. The exact interpretation of coverage fields should be checked for the BLAST program and output format being used. Multiple high-scoring segment pairs may cover different parts of a query, so a single alignment’s coverage should not automatically be treated as total query coverage.
- A further example using Biopython demonstrates how a protein alignment can be generated and inspected with a substitution matrix.
from Bio.Align import PairwiseAligner, substitution_matrices
seq1 = “MKTAYIAKQRQISFVKSHFSRQ”
seq2 = “MKTAYIAKQKQISFVKSHFSRQ”
aligner = PairwiseAligner()
aligner.mode = “global”
aligner.substitution_matrix = substitution_matrices.load(“BLOSUM62”)
aligner.open_gap_score = -10
aligner.extend_gap_score = -0.5
alignments = aligner.align(seq1, seq2)
print(“Alignment score:”, alignments.score)
print(alignments[0])
- This example produces a global protein alignment using BLOSUM62 and affine gap penalties. The alignment can then be examined to identify identical residues, positive-scoring substitutions, and gaps. The alignment score is not itself a percentage identity or similarity value; these statistics must be calculated or obtained separately.
- Several factors can affect the interpretation of alignment statistics. Short alignments may produce high identity by chance, especially in repetitive or low-complexity regions. Long sequences may contain conserved domains separated by unrelated regions, making whole-sequence identity misleading. Gaps may be placed differently by different algorithms or scoring parameters, particularly in repetitive sequences. Ambiguous nucleotide symbols and unknown amino acid residues can also influence identity calculations. For these reasons, researchers should inspect alignment coordinates, sequence lengths, gap patterns, conserved domains, and statistical significance rather than relying on a single percentage.
- It is also important to distinguish sequence identity from homology. Homology describes a common evolutionary origin and is not expressed as a percentage. Sequences may be homologous even when their identity is relatively low, particularly when they are distantly related. Conversely, a short region of high identity does not automatically establish that two complete sequences are homologous. Evidence from alignment length, coverage, conserved domains, structural similarity, phylogenetic relationships, and biological context can strengthen an evolutionary interpretation.
- Reproducible alignment analysis requires reporting the software, version, alignment mode, substitution matrix, gap-opening and gap-extension penalties, treatment of terminal gaps, and rules used to calculate identity and coverage. Researchers should also retain the original sequences, alignment files, and relevant database versions. These details make it possible to reproduce the analysis and compare results across studies.
- Alignment identity, similarity, coverage, and gaps provide complementary information about the relationship between biological sequences. Identity measures exact matches, similarity captures conservative substitutions, coverage describes the extent of sequence representation, and gaps reveal length differences within the alignment. Together with alignment scores and statistical significance, these measures form an essential foundation for reliable sequence comparison, functional annotation, evolutionary analysis, and interpretation of bioinformatics search results.