Pairwise Sequence Aligner and MSA Viewer
Operator: Abdulla Al Fahad. How tools are built and checked
A pairwise alignment is a claim about which positions of two sequences descend from the same position of an ancestor, and its score depends entirely on the choices behind it: the substitution matrix, the price of opening a gap and the price of extending one. This page makes those choices visible and reports exactly what was used.
Two modes share the page. Align two sequences runs Needleman-Wunsch (global) or Smith-Waterman (local) with affine gaps. View an alignment opens an already aligned FASTA or Clustal file and shows a coloured, scrollable block with conservation, a consensus and a pairwise identity table.
It does not build multiple alignments; a file that comes from MUSCLE, MAFFT, Clustal Omega or any other aligner is read, not re-aligned.
Key features
- Global alignment (Needleman and Wunsch 1970) and local alignment (Smith and Waterman 1981) from the same three-state affine-gap recurrence (Gotoh 1982)
- BLOSUM62 (Henikoff and Henikoff 1992) and PAM250 (Dayhoff) for protein; user-set match and mismatch for DNA and RNA, where U equals T and N scores 0
- Optional free end gaps in global mode, so a short sequence can sit inside a long one without a penalty for the overhang
- Identity, similarity (columns scoring above 0 in the matrix), gap count and number of gap openings, with the aligned stretch of each sequence
- Work happens in a background worker with a progress figure and a Cancel button; pairs up to 30,000 residues each, and 40 million cells for the two lengths multiplied
- Alignment viewer with Clustal-style residue classes, hydrophobicity (Kyte-Doolittle) or conservation shading, a per-column conservation bar and a consensus with a threshold you set
- Downloads: report TXT and aligned FASTA for a pair; consensus FASTA, per-column conservation CSV and an identity matrix CSV for an alignment
Scoring, the affine gap convention and how alignment files are read
A gap of k positions costs open + (k - 1) x extend. The first gap position is charged the opening cost and every further one the extension cost, which is the convention of EMBOSS needle and water. Setting the two equal gives the linear gap penalty used in the textbook versions of the algorithms, and the page requires extend not to exceed open, because otherwise a long gap would be cheaper as several separate openings.
Both sequences are upper-cased and anything that is not a letter or * is dropped. In protein mode, B, Z and X use their own matrix rows, and any other letter is scored as X. The type is detected from the residues: a sequence that is almost all A, C, G, T, U and N is taken as nucleotide, and the Sequence type box overrides the guess.
Aligned FASTA files must have every record the same length, with - or . for gaps. Clustal files are recognised by a CLUSTAL, MUSCLE or MAFFT header or by name-and-sequence blocks; the conservation line made of * : and . characters is ignored, because the page recomputes conservation itself. If sequences differ in length, the first one that does is named in the error.
The viewer reads up to 20 MB of text, 2,000 sequences and 100,000 columns. It shows 100 columns of 40 sequences at a time, with buttons and a slider to move along the alignment, and the identity matrix is limited to 200 sequences and 400 million column comparisons (sequences times the other sequences, halved, times columns) because it compares every pair column by column.
In pair mode a FASTA file can hold up to 500 listed records, and the first two fill the boxes; the other records stay available in the pick lists. Only the first record in a box is used, and the report and aligned FASTA carry the first word of each header as the sequence name.
How it works
For sequences of length m and n the recurrence fills three tables: H, the best score ending anywhere, E, ending in a gap in A, and F, ending in a gap in B. Each cell is the maximum of a diagonal move plus the substitution score, opening or extending a gap from the left, and opening or extending a gap from above. Local mode adds 0 as a fourth choice and starts the traceback at the highest cell.
Scores are kept in two rows, and one byte per cell records the traceback choices, so a 6,000 by 6,000 pair needs about 36 MB and the 40 million cell cap needs 40 MB. The cap exists so a mistaken whole-genome paste ends in a message instead of a frozen tab.
With end gaps unpenalised, the first row and column start at 0 and the final score is the best value in the last row or column; the sequence left over is written as end gaps.
Conservation of a column is the share of residues, among sequences that are not gapped there, that equal the most common one. The consensus shows the residue only when it reaches the threshold as a share of all sequences, and shows - when at least half of them have a gap.
Common use cases
- A student checks a homework answer: GCATGCG against GATTACA with +1, -1 and gap 1 gives score 0 and GCA-TGCG over G-ATTACA, the example in Wikipedia's Needleman–Wunsch article.
- A biologist compares a 450-residue enzyme with its homologue in another species using BLOSUM62, gap open 10 and extend 0.5, and reads the identity and similarity percentages for a figure legend.
- A primer designer aligns a 24-base primer against a 1,200-base amplicon with end gaps unpenalised, so the overhang of the long sequence costs nothing.
- A PI opens a 31-sequence Clustal file from a collaborator, finds the 12 fully conserved columns around an active site, and downloads the consensus.
How to use this tool
- Choose Align two sequences and paste both sequences or drop a FASTA file; a file with several records lets you pick which two.
- Select global or local, then the matrix (or DNA scores) and the two gap costs.
- Press Align; for long pairs watch the progress figure or press Cancel.
- Read the score and identity, and check the alignment blocks, where | marks identical residues.
- Download the TXT report or aligned FASTA.
- For a finished alignment, switch to View an alignment, load the file and move along the columns.
Example
DNA pair, local: TGTTACGG against GGTTGACTA, match +3, mismatch -3, gap open 2, gap extend 2
>local_A
TGTTACGG
>local_B
GGTTGACTAThe local alignment and its statistics
Score 13, 6 columns, 5 identical (83.3%), 1 gap
A covered 2-6 of 8; B covered 2-7 of 9
GTT-AC
||| ||
GTTGACTips for best results
- For divergent proteins try PAM250 beside BLOSUM62; for close homologues BLOSUM62 with open 10 and extend 0.5 is a common starting point.
- Use local mode to find a shared domain in two otherwise unrelated sequences, and global mode when the sequences should match end to end.
- In the viewer, set the consensus threshold to 100 to list only columns identical in every sequence.
Common pitfalls
Several different alignments can share the best score. The page reports one; a tie is decided in the order diagonal, then gap in A, then gap in B.
Local mode reports only the single best segment. A second shared domain with a lower score is not shown.
Identity is divided by the alignment length, gaps included, so it is lower than identity over aligned columns only. The identity matrix in the viewer divides by shared columns instead; the two are different numbers.
A DNA alignment with the default +5 and -4 is not tuned for distant sequences; protein alignment is usually more sensitive for coding sequences.
The viewer does not check that the file is a true alignment: a set of unrelated sequences padded with gaps is displayed as it is.
Common errors and how to fix them
- The sequences are 7,000 and 7,000 long; their product is over the 40,000,000-cell limit.
- Align a region of each sequence, or trim to the part you care about. The limit protects the browser's memory, and a pair near 6,300 by 6,300 still fits.
- The gap extension cost cannot be larger than the gap opening cost.
- Swap the two numbers or set them equal. Typical protein pairs use 10 and 0.5, or 11 and 1.
- "seq3" has 118 columns but "seq1" has 120.
- The file is not an alignment: the sequences were not padded to a common length. Re-export it from the aligner as aligned FASTA or Clustal.
- No stretch of these sequences scores above 0 under this scoring, so there is no local alignment.
- A local alignment needs at least one positive-scoring match. Raise the match score, or lower the mismatch and gap costs, until a segment scores above 0.
- 200 sequences of 100,000 columns is 1990 million pair comparisons; the identity matrix stops at 400 million.
- Use fewer sequences or a shorter alignment; the viewer, consensus and conservation still work on the full file.
- For DNA, the match score must be positive and the mismatch score negative.
- Enter the mismatch as a negative number such as -4; the gap costs are entered as positive costs.
Best practices
- Record the matrix, both gap costs and the mode next to any reported score, since the same pair gives different scores under different settings.
- Translate coding DNA and align the protein when the sequences are more than about 70% different.
- Keep names in an aligned FASTA short and unique; the viewer shows the first word of each header.
What the viewer's colours mean
Residue classes use Clustal-style groups in this page's own colours (they match neither EBI's nor ClustalX's palette): hydrophobic residues (A, V, F, P, M, I, L, W) blue, acidic D and E red, basic R and K magenta, polar S, T, N and Q green, C pink, G orange, and H and Y cyan. Nucleotides use one colour each.
Hydrophobicity shading uses the Kyte-Doolittle scale in three bands: strongly hydrophobic residues (above 1.5) in red, intermediate in yellow and hydrophilic in blue. Column conservation shades a whole column green by how many residues agree, from fully identical to 60% or more.
What the gap penalties do to one pair
For the protein pair HEAGAWGHEE and PAWHEAE from Durbin and colleagues' Biological Sequence Analysis with BLOSUM62 and end gaps penalised, gap open 10 and extend 0.5 give a global score of 4 with a single 3-column gap at the start. Opening at 5 with extend 1 gives 14 and a different alignment, HEAGAWGHE-E over ---PAW-HEAE, with three gaps. At open 3 and extend 3 (a linear penalty) the score is 17 with four gaps, and at open 20 and extend 2 the score falls to -9 because every gap is expensive.
With end gaps made free the same pair scores 15, since the overhangs cost nothing. The point is that the score is not a property of the two sequences alone: it depends on the penalties as much as on the matrix.
Frequently asked questions
Why does my score differ from the one another aligner reports?
Check the gap convention first. Some programs charge open + k x extend for a gap of k, others open + (k - 1) x extend as here, and a few add end-gap rules. With the same matrix and the conventions matched, the scores agree.
Can I align more than two sequences?
Not here. Use an aligner such as Clustal Omega, MUSCLE or MAFFT, and open its output in the viewer.
What is the difference between identity and similarity?
Identity counts columns with the same residue. Similarity also counts different residues whose substitution score is above 0, such as I and V in BLOSUM62, so it is only reported for protein.
Does it handle RNA?
Yes. U is scored as T, so an RNA sequence aligns against its DNA counterpart as if the bases were the same.
Can I give it an alignment with lowercase letters or dots?
Yes. Letters are upper-cased and dots are read as gaps, which is how some Clustal-style outputs write them.