What is Sequence Search?
BLAST Concepts
Understand why sequence similarity search was invented, how BLAST thinks about your DNA, and master the vocabulary — E-value, bit score, HSP — that appears in every paper you will ever read.
Why Does Sequence Search Exist?
You have just sequenced an unknown gene from a wild rice variety. You have a string of A, T, G, C letters — but you have no idea what this gene does. How do you find out? You ask: "Has anyone seen a similar sequence before, and if so, what did it do in that organism?" That is sequence similarity search in one sentence.
Before the internet era, biologists had to manually compare sequences on paper — a completely impractical task once databases grew beyond a few hundred sequences. The question was: how do you efficiently find the needle (your query) in a haystack of millions of known sequences?
The naive approach — align your query against every single database entry using dynamic programming (the Smith-Waterman algorithm) — gives perfect results but is too slow for large databases. BLAST was invented in 1990 specifically to solve this speed problem while remaining accurate enough for practical biology.
Sequence search is used in bioinformatics for:
- Gene annotation — assigning function to newly sequenced genes by finding similar genes in model organisms
- Evolutionary analysis — finding orthologues (same gene, different species) and paralogues (duplicated genes)
- Primer design — checking that your PCR primers are specific and won't amplify off-target regions
- Contamination detection — checking whether your RNA-seq data contains sequences from an unexpected organism
- Metagenomics — identifying organisms in environmental samples by matching reads to known genomes
What is BLAST?
BLAST stands for Basic Local Alignment Search Tool. It searches a sequence database for regions that are locally similar to your input sequence. "Local" is the key word: BLAST does not require your query to align across its full length — it finds the best-matching regions, even if the rest of the sequence is totally different.
The word local distinguishes BLAST from global alignment tools like Needleman-Wunsch, which try to align two sequences from end to end. Local alignment is more useful for biology because:
- Genes often share only functional domains, not their entire sequence
- Proteins from distantly related organisms may share a conserved catalytic site but differ everywhere else
- Your query (a 200 bp fragment) is often much shorter than the database sequence (a 50 kb chromosome)
BLAST was created at the NCBI (National Center for Biotechnology Information) and is available both as a web tool at ncbi.nlm.nih.gov/blast and as a standalone command-line program you install locally. In this module, we focus on the command-line version — because that is what you use in automated pipelines.
BLAST Flavours — Which One Do You Use?
BLAST is not a single program — it is a family of programs, each designed for a specific combination of query type and database type. Choosing the wrong one is a common beginner mistake.
| Program | Query type | Database type | When to use |
|---|---|---|---|
| blastn | nucleotide | nucleotide | Find similar DNA/RNA sequences; check primer specificity |
| blastp | protein | protein | Find similar proteins; annotate protein function |
| blastx | nucleotide | protein | Translate DNA in all 6 frames and search protein DB — great for gene prediction |
| tblastn | protein | nucleotide | Search translated nucleotide DB with a protein query — find genes in unannotated genomes |
| tblastx | nucleotide | nucleotide | Translates both sides; slowest but most sensitive for distant homology |
| dc-megablast | nucleotide | nucleotide | Very fast for highly similar sequences (e.g. same species variants) |
blastx is especially powerful — you take your newly assembled transcript, translate it in all 6 frames, and instantly check whether it matches any known plant protein in UniProt. This is how gene function is predicted in genome annotation pipelines.Key Concepts You Must Know
BLAST output contains a set of statistics that look intimidating at first but each has a precise biological meaning. You will see these in every paper, every pipeline, and every database result page.
| Term | What it measures | Good value means |
|---|---|---|
| E-value | Expected number of hits this good by random chance in a database of this size | Smaller is better. E < 1e-5 = significant; E < 1e-50 = very confident |
| Bit score | A normalised alignment quality score (independent of database size) | Higher is better. Comparable across different BLAST runs |
| % Identity | Percentage of aligned positions that are identical | Higher is better. >90% = likely same gene; 30–50% = likely same protein family |
| % Coverage | How much of your query aligns to the subject | Higher is better. Low coverage (<50%) may mean only a domain matches |
| HSP | High-scoring Segment Pair — a local alignment region | Each hit may have multiple HSPs; take the best one |
| Raw score | Sum of match scores minus gap penalties in the alignment | Depends on scoring matrix used; bit score is the normalised version |
E-value: A Deep Dive
The E-value is the expected number of hits at least as good as your alignment that you would find purely by chance if you searched a database of this size with a random sequence. It is not a probability of a single hit — it is an expectation over the whole database. An E-value of 0.01 means you expect 1 false positive per 100 searches of this database.
The E-value depends on three things:
- The alignment score — higher scores give lower E-values
- The database size — a larger database gives a higher E-value for the same score (more chances for a random hit). This is why you cannot compare E-values from different databases directly
- The scoring matrix — BLOSUM62 for proteins, match/mismatch scores for DNA
The formula behind E-value is:
HSPs — High-Scoring Segment Pairs
An HSP (High-Scoring Segment Pair) is a contiguous region of alignment between your query and a database sequence that has no gaps and achieves a high alignment score. BLAST reports one or more HSPs per database hit. Multiple HSPs for a single hit usually indicate repeated domains or multiple exons matching the same database entry.
BLAST output shows HSPs like this (pairwise format):
Score = 285 bits (308), Expect = 2e-75
Identities = 147/158 (93%), Gaps = 0/158 (0%)
Strand = Plus/Plus
Query 1 ATGGTCAAGCTCGTCGACGAGCTCATCACCAACGAGAAGGACCCCAACATCAAGCTGAC 60
|||||||||||||||||||||||||||||| ||||||||||||||||||| ||||||||||
Sbjct 203 ATGGTCAAGCTCGTCGACGAGCTCATCATCAACGAGAAGGACCCCAACATCAAGCTGAC 262
Query 61 CGAGCAGCTCAAGAAGGAGATCGAGCGCATGCTGCACAAGGAGCCCGTCGACGTCACCA 120
|||||||||||||||||| ||||||||||||||||||||||||||||||||||||||||||
Sbjct 263 CGAGCAGCTCAAGAAGGATATCGAGCGCATGCTGCACAAGGAGCCCGTCGACGTCACCA 322
Reading an HSP:
- Score — the raw + bit score pair. Bit score is in parentheses here; in tabular output it appears as a separate column
- Expect — the E-value for this HSP against this database
- Identities — matches / total aligned length. Pipes (
|) show identical positions - Gaps — number of gap characters inserted to improve the alignment
- Query / Sbjct lines — the actual aligned sequences with coordinates
How BLAST Works: The Algorithm in Plain English
BLAST achieves its speed through a clever heuristic — it avoids checking every possible alignment and instead uses a seed-and-extend strategy:
makeblastdb step (building the database index) is done once and stored on disk. Every subsequent BLAST search against that database reuses the index — this is why local BLAST is much faster than re-scanning raw FASTA files. You will do this in Lesson 2.Smith-Waterman is the gold-standard exact local alignment algorithm — it is guaranteed to find the best alignment. BLAST is a heuristic (an approximation) — it is fast but can miss very short or very divergent alignments. For most bioinformatics work, BLAST is more than sufficient. For critical decisions (e.g. confirming gene family membership), you may want to follow up with a full Smith-Waterman alignment or profile-based tools like HMMER.
Exercises
You have assembled a new transcript from Sorghum bicolor and want to find similar proteins in the UniProt database. Which BLAST program should you use, and why?
▶ Show answer
# Use blastx # Reason: your query is a nucleotide (transcript = DNA/RNA), # but UniProt is a protein database. # blastx translates your nucleotide query in all 6 reading frames # and searches a protein database — perfect for gene annotation. # blastn would be wrong: it searches a nucleotide DB # blastp would be wrong: it requires a protein query
You run a BLAST search and your top hit has E-value = 3e-82. Your second hit has E-value = 0.04. Which hit is more reliable, and would you accept the second hit as evidence of homology?
▶ Show answer
# Hit 1 (E = 3e-82) is far more reliable. # An E-value of 3e-82 means you would expect this good an alignment # to occur by chance only 3 × 10^-82 times — essentially never. # This is very strong evidence of true homology. # Hit 2 (E = 0.04) is borderline. # You would expect ~0.04 false positives per search at this score. # Standard threshold is E < 1e-5 for significance. # Most researchers would NOT accept E = 0.04 as evidence of homology # without additional evidence (e.g. conserved domain, phylogeny).
You search sequence A against database X (10,000 sequences) and get E = 1e-8. Your colleague searches the same sequence against NCBI nr (200 million sequences). Will their E-value be larger or smaller? Why?
▶ Show answer
# Their E-value will be LARGER (less significant). # E-value = K × m × n × e^(-λ × S) # where n = effective database size. # NCBI nr has ~20,000× more sequences than your local DB. # So for the same alignment score S, the E-value scales proportionally: # your E = 1e-8 # colleague's E ≈ 1e-8 × 20000 ≈ 2e-4 # This does NOT mean the alignment is worse — the underlying biology # is the same. It just means there are more random hits in a bigger DB. # Always report which database you searched when reporting E-values!
An HSP shows: Score = 420 bits, Expect = 5e-118, Identities = 198/210 (94%), Gaps = 2/210 (1%). In plain English, what does this tell you about the relationship between your query and the database sequence?
▶ Show answer
# This is an extremely high-confidence match. # Score = 420 bits → very high alignment quality # E = 5e-118 → essentially impossible to see by chance # Identities = 94% → 198 out of 210 positions are identical # Gaps = 1% → only 2 gap characters in 210 bp alignment # Conclusion: this query and the database sequence are # almost certainly the same gene or very recently diverged # orthologues (e.g. same gene in closely related species). # The 6% difference could be due to SNPs or allelic variation.
Your progress is saved in your browser.