Mini-Course: Sequence Alignment & BLAST

Aligning sequences is the most fundamental operation in bioinformatics, and BLAST is the tool that built the field. This focused, professional mini-course takes you from the idea of homology through how alignment actually works, how to run and correctly read a BLAST search, and how to align many sequences at once. It ends with a graded final assessment that tests real understanding.

๐ŸŽ“ Mini-course โฑ๏ธ ~2 hr ๐ŸŒ Web tools + optional install โœ… Graded assessment

What you'll be able to do

  • Explain homology and distinguish global from local alignment.
  • Describe how pairwise alignment is computed (scoring, gaps, substitution matrices).
  • Run a BLAST search and correctly interpret E-value, bit score, percent identity, and coverage.
  • Choose the right BLAST program and database for a question.
  • Build and read a multiple sequence alignment.

Before you start

Module 1 of 4

Learning objectives

By the end of this lesson you will be able to: explain homology versus similarity, run a BLAST search, and read an E-value and query coverage correctly.

Why we align: homology and similarity

Two sequences that look alike usually look alike for a reason: they descend from a common ancestor. That shared ancestry is called homology, and detecting it is the engine behind an enormous amount of biology. If your unknown sequence aligns well to a well-studied gene, you can transfer what is known about that gene as a hypothesis about yours: its function, its structure, its family.

A crucial distinction that trips people up: similarity is a measurement (how alike two sequences are, as a number), while homology is a conclusion (they share an ancestor). High similarity is evidence for homology, but you infer homology, you do not measure it. Homology is also all-or-nothing: two sequences are either related or not; there is no such thing as "40% homologous" (that phrase means 40% identical).

There are two flavours of alignment, and choosing correctly matters:

  • Global alignment stretches the two sequences end to end. Use it when the sequences are roughly the same length and you expect them similar along their whole span.
  • Local alignment finds the best-matching subregion and ignores the rest. Use it when you are hunting a shared domain or motif inside otherwise different sequences. BLAST is fundamentally a local-alignment search, which is exactly why it is so useful for database hunting.
Module 2 of 4

How pairwise alignment actually works

๐Ÿ“˜ New to this? This module shows what happens under the hood. You can skim it on a first pass and still use BLAST well, the most practical, job-ready skills are in Modules 3 and 4.

An alignment is scored: you reward matches, penalise mismatches, and penalise gaps (insertions or deletions). The "best" alignment is the one with the highest total score. The breakthrough that made this tractable was dynamic programming: instead of trying every possible alignment (astronomically many), you build the optimal alignment from optimal sub-alignments in a scoring matrix.

Decode the jargonDynamic programming

A problem-solving trick: instead of re-checking every possibility from scratch, you solve tiny sub-problems once, store the answers, and reuse them. For alignment it means filling a grid cell by cell, so the best alignment of two long sequences is assembled from the best alignments of their shorter pieces. You never have to code this yourself, the tools do it; this is just so the word is not a mystery.

  • Needleman-Wunsch (1970) is the dynamic-programming algorithm for global alignment.
  • Smith-Waterman (1981) is the variant for local alignment. It is exact but slow on big databases, which is the gap BLAST was invented to fill.

Decode the jargonSubstitution matrix

For proteins, not all mismatches are equal: swapping two chemically similar amino acids is far less disruptive than swapping two very different ones. A substitution matrix (the BLOSUM and PAM families; BLOSUM62 is the common default) assigns a score to every possible residue-to-residue substitution, based on how often it is observed in real related proteins. This is why protein alignment is more sensitive than raw DNA matching.

See dynamic programming run (in your browser)

The cell below is a complete Needleman-Wunsch global aligner in pure Python, no libraries. It fills the scoring matrix, then traces back the optimal alignment. Press Run (the first run loads Python in your browser), then change the sequences or the match/gap scores and watch the alignment change. You do not need to understand every line of the code, just press Run and watch the output.

Module 3 of 4

BLAST, done right

BLAST (Basic Local Alignment Search Tool) is a fast heuristic for the same problem: given your query, find the best local alignments against a huge database in seconds. It does this by first finding short exact "word" matches and only then extending the promising ones, trading guaranteed optimality for enormous speed. It is, by citation count, one of the most influential tools ever published.

First, pick the right program for your sequences:

ProgramQueryDatabase
blastnnucleotidenucleotide
blastpproteinprotein
blastxnucleotide (translated)protein
tblastnproteinnucleotide (translated)

For function questions, prefer protein-level searches (blastp, blastx): protein sequence is more conserved than DNA, so it detects more distant relationships.

Hands-on: run a BLAST search

No install needed for this part. Go to the NCBI BLAST site, choose blastn or blastp, paste a FASTA sequence, pick a database (start with nr), and run it. Then read the results, which is the skill most people get wrong.

๐Ÿงช Try this exact example (recommended for your first time)

Open UniProt P68871 (human hemoglobin subunit beta, "HBB"), copy its protein sequence, and run blastp against nr. What you should see: the top hit is human beta-globin itself at ~100% identity with an E-value at or near 0; just below it, beta-globins from other mammals (chimp, mouse, and so on), lower percent identity but still tiny E-values. Those lower-identity hits are real homologs, which is exactly the homology-vs-identity point from Module 1.

โš ๏ธ Read the E-value, not just the percent identity

The numbers that decide whether a hit is real:

E-value (Expect value): the number of hits this good you would expect by chance in a database this size. Smaller is better. E = 1e-50 is rock solid; E = 2 means you would see two such "hits" at random, so it is meaningless. This is the single most important number, and the most misread.
Bit score: the alignment quality, normalised so it is comparable across searches and database sizes. Higher is better.
Percent identity: how much of the aligned region matches exactly. High identity over a tiny region can still be junk, which is why you must also check
Query coverage: how much of your sequence the alignment actually spans. 98% identity over 9% of your query is usually not the answer you want.

๐Ÿ› ๏ธ Go professional: command-line BLAST+

The web tool is great for one sequence; real work runs thousands. Install the command-line suite once and you can script it: conda install -c bioconda blast (see the Conda mini-lesson), then build a database with makeblastdb and search with blastn -query q.fa -db mydb -evalue 1e-5 -outfmt 6. The tabular -outfmt 6 output is what you parse in a pipeline. This is the same BLAST+ from Camacho et al. (2009) cited below.

Module 4 of 4

Aligning many sequences: MSA

A multiple sequence alignment (MSA) lines up three or more sequences at once, revealing the columns that are conserved across a whole family. Conserved columns often mark functionally critical residues (an active site, a binding pocket), and an MSA is the starting point for building phylogenetic trees, profiles, and HMMs.

Because the exact solution is computationally explosive for many sequences, MSA tools use progressive and iterative heuristics. The standard, free tools are Clustal Omega and MUSCLE; both run with no install through the EMBL-EBI web services.

Decode the jargonConserved column

A position in an MSA where most or all sequences share the same (or chemically similar) residue. Strong conservation across distantly related sequences is a strong hint that the position matters for function, because evolution did not let it drift. Reading conservation is a core skill MSAs unlock.

โœ… Final assessment

Five questions covering the whole mini-course. Aim for at least 4 out of 5 correct. These are reasoning questions, not recall, so treat it like the real thing.

A colleague says two proteins are "60% homologous." Why is this statement technically wrong, and what did they most likely mean?
Correct. Similarity/identity is measured as a number; homology is a conclusion (shared ancestry) that is all-or-nothing. "60% homologous" conflates the two. The sound phrasing is "60% identical," which is evidence for, but not the same as, homology.
You want to find which conserved protein domain sits inside two otherwise very different long proteins. Which alignment type is appropriate, and which classic algorithm computes it exactly?
Exactly. Finding a shared subregion inside otherwise dissimilar sequences is a job for local alignment. Smith-Waterman (1981) computes the optimal local alignment exactly; BLAST is the fast heuristic approximation that makes local search across whole databases practical.
Two BLAST hits to your query: Hit A has 99% identity, E-value 4, query coverage 7%. Hit B has 41% identity, E-value 2e-60, query coverage 95%. Which is the more trustworthy match and why?
Right. Percent identity alone is a trap. Hit A's E-value of 4 means you would expect several such matches by chance, and it spans only 7% of the query, classic noise. Hit B's E-value of 2e-60 over 95% coverage is a real, significant homolog despite lower identity.
You have an unknown DNA sequence and want the most sensitive search for its likely function. Which BLAST strategy is best, and why?
Correct. For function, search at the protein level: proteins tolerate synonymous and conservative changes, so they stay recognizable over far greater evolutionary distance than DNA. blastx translates your nucleotide query in all frames and searches a protein database, the most sensitive choice for a function question.
In a multiple sequence alignment of a protein family, one column is identical across all 30 sequences, including very distantly related ones. What is the most reasonable interpretation?
Exactly. A column conserved even among distant relatives is unlikely to be chance: purifying selection kept it fixed, which usually signals a residue essential for function or structure. Reading conservation this way is one of the main reasons to build an MSA.

Sources & further reading

  1. Needleman SB, Wunsch CD. A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 48:443โ€“453, 1970. (Global alignment by dynamic programming.)
  2. Smith TF, Waterman MS. Identification of common molecular subsequences. J Mol Biol 147:195โ€“197, 1981. (Local alignment.)
  3. Altschul SF, Gish W, Miller W, Myers EW, Lipman DJ. Basic local alignment search tool. J Mol Biol 215:403โ€“410, 1990. (The original BLAST.)
  4. Camacho C, et al. BLAST+: architecture and applications. BMC Bioinformatics 10:421, 2009. doi:10.1186/1471-2105-10-421
  5. Sievers F, et al. Fast, scalable generation of high-quality protein multiple sequence alignments using Clustal Omega. Mol Syst Biol 7:539, 2011. doi:10.1038/msb.2011.75
  6. Curriculum alignment: EMBL-EBI Training, Galaxy Training Network (Sequence analysis), and the ISCB bioinformatics core competencies (Mulder et al., PLOS Comput Biol, 2018).

Last reviewed: June 2026.

Ready for more? Level 2

Sequence Alignment & BLAST โ€” Advanced โ†’