DNA Sequence Alignment Matrix Calculator
Compare two DNA sequences using the Needleman-Wunsch global alignment algorithm. Generate the dynamic programming scoring matrix, find an optimal alignment, and calculate sequence identity and alignment score.
Enter DNA Sequences
Enter two DNA sequences containing A, C, G, T or N. Spaces and line breaks are automatically ignored.
Alignment Scoring Parameters
Choose the scores used to compare nucleotides and penalize gaps. The gap penalty is entered as a positive number and subtracted during the calculation.
Match = positive score. Mismatch = negative penalty. Gap = negative penalty for each gap position. This calculator uses a linear gap penalty.
How DNA Sequence Alignment Works
DNA sequence alignment is a computational method for comparing nucleotide sequences. It helps identify identical positions, substitutions, insertions and deletions between two sequences.
This calculator uses the Needleman-Wunsch algorithm, a dynamic programming method for global alignment. Global alignment attempts to align both complete sequences from beginning to end.
Scoring matrix recurrence
Where:
- F(i,j): Best score for aligning the first i and j nucleotides.
- S(xᵢ,yⱼ): Match or mismatch score for the two nucleotides.
- g: Positive gap penalty subtracted from the score.
- Diagonal movement: Aligns two nucleotides.
- Vertical movement: Inserts a gap in sequence 2.
- Horizontal movement: Inserts a gap in sequence 1.
Initialization
The first row and first column represent aligning a sequence against gaps. Each additional gap incurs another gap penalty.
Traceback
Once the scoring matrix is complete, traceback begins at the bottom-right cell. The algorithm follows the recorded optimal directions back to the top-left cell to reconstruct the alignment.
Sequence identity
The alignment length includes positions containing gaps. Identity is a simple measure of exact nucleotide matches and does not by itself establish biological function or evolutionary relationship.
This tool performs global pairwise alignment with a linear gap penalty. It does not perform local alignment, multiple sequence alignment, affine gap scoring, or biological variant interpretation. It accepts A, C, G, T and N, where N represents an unknown or ambiguous nucleotide. It is intended for educational and exploratory analysis, not clinical or diagnostic use.
Frequently Asked Questions
What is DNA sequence alignment?
DNA sequence alignment compares nucleotide sequences by arranging their bases into corresponding positions. Gaps may be introduced to account for insertions or deletions.
What algorithm does this calculator use?
It uses the Needleman-Wunsch algorithm, a dynamic programming algorithm designed for optimal global alignment of two sequences.
What is the difference between global and local alignment?
Global alignment attempts to align the entire length of both sequences. Local alignment identifies the highest-scoring matching regions within the sequences.
What are match, mismatch and gap scores?
A match score rewards identical nucleotides. A mismatch penalty reduces the score for different nucleotides. A gap penalty discourages insertions and deletions.
What does sequence identity mean?
Sequence identity is the percentage of aligned positions containing exactly the same nucleotide in both sequences.
What does N mean in a DNA sequence?
N is an ambiguity symbol meaning that the nucleotide at that position is unknown or cannot be determined. In this calculator, N matches another N but is treated as a mismatch against A, C, G or T.
Can I download the alignment results?
Yes. Use the CSV download button to export the scoring matrix, aligned sequences, alignment score and statistics.
Does this calculator identify mutations?
It can show mismatches and gaps in an alignment, but it does not classify or interpret biological mutations. Further biological analysis is needed to determine their significance.
Related Matrix and Biology Tools
Explore other mathematical and computational tools.