Lesson 8 of 9
Module 4 · Comparing sequences
One changed base can do nothing, swap an amino acid, stop the protein or scramble it. Learn the types of change, how to name them in HGVS, how tools like the Ensembl VEP annotate them, and how to classify one in Python.
From a changed base to a changed protein
The lessons from Global and local alignment, without heavy maths to Trees from sequences compared sequences from different genes and species. This lesson compares two versions of the same sequence: a reference and a variant, a difference found, for example, in one patient's DNA. The question is always the same: what does this change do?
A variant is a difference from the reference, not a mistake in the patient. The reference genome is one assembled sequence, and at some positions it even carries the less common of two versions found in people. So "variant" says only that the sample differs from this reference at this position. Whether the difference matters is a separate question, and this lesson answers the first part of it: what the change does to the gene's message.
The answer depends first on where the change falls. Most of the genome does not code for protein, and a change there may alter how much of a gene is made, or nothing at all. This lesson deals with changes in and next to the coding sequence, the part of the mRNA that is read three bases at a time, as codons, from the start codon ATG to a stop codon. The grouping into threes is the reading frame. Because 64 codons encode only 20 amino acids and a stop signal, many amino acids have several codons; this redundancy is why some changes alter nothing.
Changes outside the coding sequence are not automatically harmless. The stretches of mRNA before the start codon and after the stop codon, the untranslated regions or UTRs, help control how long the mRNA lasts and how much protein is made from it. Further out, the DNA that switches a gene on, such as its promoter, sits upstream of the first exon. Annotation tools label such changes too, with terms such as 5_prime_UTR_variant or upstream_gene_variant, but their effect is much harder to predict from sequence alone.
The kinds of change
The examples come from the human haemoglobin beta gene, HBB, the same protein you aligned in Multiple alignment and conserved regions and Trees from sequences. Variants marked "teaching example" were chosen to show the type; the others are well-known variants.
| Type | What happens | HBB example | VEP term · impact |
|---|---|---|---|
| Synonymous | A base changes but the codon still means the same amino acid. | c.21G>A, GAG to GAA, both glutamate (teaching example) | synonymous_variant · LOW |
| Missense | One amino acid is replaced by another. | c.20A>T, p.Glu7Val: sickle-cell haemoglobin | missense_variant · MODERATE |
| Nonsense | A codon becomes a stop codon, so the protein is cut short. | c.118C>T, p.Gln40Ter: a cause of beta thalassaemia | stop_gained · HIGH |
| Frameshift | Bases are lost or added in a number that is not a multiple of 3. Every codon after it is read in the wrong frame. | c.20del (teaching example) | frameshift_variant · HIGH |
| In-frame indel | A multiple of 3 bases is lost or added. Amino acids are removed or inserted, but the rest of the protein is read normally. | c.25_27del, p.Lys9del (teaching example) | inframe_deletion · MODERATE |
| Splice | The change hits the signal at an exon–intron boundary, so the intron may not be cut out correctly. | c.92+1G>A: the first base of intron 1, a cause of beta thalassaemia | splice_donor_variant · HIGH |
How to read this table
Read across each row: the name of the type, what it does to the message, an example, and how an annotation tool labels it. An indel is an insertion or deletion. The last column uses the standard consequence terms that the Ensembl VEP reports, described below, with its rough rating of impact: LOW for changes unlikely to alter the protein, MODERATE for changes that alter it without breaking it, and HIGH for changes likely to destroy it. Two warnings. Impact is a guess from the type alone, not a measurement. And the frameshift and nonsense rows usually do more than shorten the protein: an mRNA with an early stop codon is often destroyed by the cell before much protein is made, a process called nonsense-mediated decay.
The redundancy of the code is not spread evenly. Most of it lies in the third base of the codon: many amino acids are fixed by the first two bases, and the third can change freely, as GAG and GAA do for glutamate in the synonymous example. Changes at the first or second base almost always alter the amino acid. This is why, in an alignment of coding DNA from related species, the third positions usually vary most, a pattern you can look for in the multiple alignments of Multiple alignment and conserved regions.
How to read the figure
The top row is the reference: five codons, each labelled with its number and the amino acid it codes for, using the three-letter codes. Codon 7 is highlighted; it covers coding positions c.19 to c.21, because codon n ends at position 3n. Each card below shows one change, the new bases in vermilion, and its effect. In the frameshift card, the dot marks where a base was lost: the next three bases form a new codon, and so on to the end. In the in-frame card, the whole of codon 9 is gone, but codon 10 (TCT) follows in the right frame.
Go deeper: when a coding change also acts on splicing
The categories in the table are tidy, but one change can act in two ways. Haemoglobin E, very common in South-East Asia, is HBB c.79G>A, p.Glu27Lys: by the table, a missense change. The same base change also creates a new splice signal inside exon 1, so some of the gene's RNA is cut in the wrong place and less normal beta chain is made. That is why it behaves as a mild form of beta thalassaemia, not just as an altered protein.
Synonymous changes can act in the same way. A change that leaves the amino acid alone can still damage a short sequence that the splicing machinery recognises. So 'synonymous' and a LOW impact rating describe the codon, not a guarantee that nothing happens.
Naming variants: a quick HGVS recap
Identifiers and cross-references: following one gene across databases and Reading a gene record and a protein record, in Module 2, introduced HGVS notation, the international standard for writing variants. Here are the parts you need for this lesson:
- c. counts along the coding sequence, with the A of the start codon ATG as 1. c.20A>T means the A at position 20 becomes T.
- Positions in introns are counted from the nearest exon: c.92+1 is the first intron base after coding position 92, and c.93-1 would be the last intron base before position 93.
- p. describes the protein, with three-letter amino acid codes: p.Glu7Val. Ter (or *) is a stop, del a deletion, and fs a frameshift. When the protein change has been predicted from DNA rather than measured, it is put in brackets: p.(Glu7Val).
- Always name the reference sequence, with its version: NM_000518.5:c.20A>T, from the HBB RefSeq transcript.
Older papers often call the sickle-cell change "Glu6Val". The two names describe the same change: the old numbering skips the first methionine, which is removed from the finished protein, while HGVS counts it. When positions disagree by one, check which numbering is in use.
Two more rules prevent common mix-ups. First, g. names count along a chromosome rather than a transcript, so the same change has a different g. number in each genome build; as Identifiers and cross-references: following one gene across databases showed, GRCh37 and GRCh38 coordinates must never be mixed. Second, when a deletion or insertion falls in a repeated stretch, it could be written at several positions, as Pairwise alignment: dot plots, scores and gaps showed for a run of T's. HGVS places it as far towards the end of the gene as possible, the 3′ rule, whereas VCF files usually place it as far to the left of the chromosome as possible. The two descriptions can look different and still be the same variant, so convert between them with a tool rather than by hand.
Annotation tools: the Ensembl VEP
Classifying one variant by hand is easy. A genome holds millions of differences from the reference, and each can affect several transcripts of a gene. Annotation tools do this work automatically. The most widely used is the Ensembl Variant Effect Predictor (VEP). You give it variants, as a VCF file, as HGVS names or as variant identifiers, on its web page, on the command line or through a web service. For every variant and every transcript it overlaps, it reports:
- the consequence, in the standard terms of the table above, with its impact rating;
- the affected codon and amino acid, and the HGVS names at c. and p. level;
- whether the variant is already known, its frequency in large population studies, and any clinical record in ClinVar (The main databases: sequences, genomes, proteins, structures);
- optional predictions of how damaging a missense change is likely to be, from tools such as SIFT and PolyPhen.
Because one variant can have different consequences on different transcripts, choose the transcript you report with care. The usual choice is the agreed reference transcript, the MANE Select transcript, which you met in Module 2. Other annotation tools, such as SnpEff and ANNOVAR, work in a similar way.
To try it, open the VEP web page, choose human, and paste a variant identifier in place of a file: rs334 is the dbSNP identifier of the sickle-cell change. The results list one row per transcript the variant touches, so even one variant can give several rows. Look for the row flagged as the MANE Select transcript and read its consequence, its p. name and any known identifier. Treat the SIFT and PolyPhen columns as predictions: they are computed from conservation and protein structure, they often disagree with each other, and on their own they are not evidence that a variant causes disease.
The VEP is described in McLaren et al. (2016), 'The Ensembl Variant Effect Predictor', Genome Biology 17:122. HGVS names follow den Dunnen et al. (2016), 'HGVS recommendations for the description of sequence variants: 2016 update', Human Mutation 37:564–569, and the current rules on the HGVS website. MANE Select is described in Morales et al. (2022), Nature 604:310–315. Consequence calls can change when gene models are updated, so report the VEP version, the Ensembl release and the transcript set used. For clinical significance, which this lesson keeps apart from consequence, the usual framework is the ACMG/AMP guideline of Richards et al. (2015), Genetics in Medicine 17:405–424.
Translating before and after in Python
This lesson needs Biopython. The sequence is real: the first 123 bases of the HBB coding sequence, copied from the RefSeq record NM_000518.5.
from Bio.Seq import Seq
# First 123 bases (41 codons) of the human HBB coding sequence, RefSeq NM_000518.5
ref = ("ATGGTGCATCTGACTCCTGAGGAGAAGTCTGCCGTTACTGCCCTGTGGGGC"
"AAGGTGAACGTGGATGAAGTTGGTGGTGAGGCCCTGGGCAGGCTGCTGGTG"
"GTCTACCCTTGGACCCAGAGG")
print(len(ref), "bases")
print(Seq(ref).translate())
def substitute(seq, c_pos, new_base):
"""Change one base. c_pos counts from the A of ATG as 1, like c. notation."""
return seq[:c_pos-1] + new_base + seq[c_pos:]
alt = substitute(ref, 20, "T") # c.20A>T
print(Seq(alt).translate())What this does
refholds the 123 bases. Python joins strings written next to each other in brackets, so the three pieces become one.Seq(ref).translate()reads the bases three at a time from the first and returns the protein, using the standard genetic code.substituteswaps one base. Python counts from 0 but c. positions count from 1, so c.20 isseq[19]: the function keeps everything before it, adds the new base, and keeps everything after.- The last two lines make the sickle-cell change c.20A>T and translate the result.
Reading the output
The reference translates to MVHLTPEEKSAVTALWGKVNVDEVGGEALGRLLVVYPWTQR, 41 amino acids, which is exactly the start of human haemoglobin beta in UniProt. In the variant, the seventh letter has changed from E (glutamate) to V (valine); everything else is the same.
Worked example · from c.20A>T to p.Glu7Val
position in codon = 20 − 18 = 2 (the middle base)
GAG → GTG · Glu → Val · p.Glu7Val
Step by step. Codon 1 is c.1–c.3, codon 2 is c.4–c.6, and so on, so position 20 falls in codon 20 ÷ 3 = 6.67, rounded up to 7. Codon 6 ends at position 18, so position 20 is the second base of codon 7. That codon is GAG, glutamate. Changing its middle A to T gives GTG, which codes for valine. Glutamate becomes valine at position 7: p.Glu7Val.
What the answer means. Glutamate carries a negative charge and valine is uncharged and water-repelling. On the surface of haemoglobin, that valine lets deoxygenated molecules stick together into long fibres, which distort red cells into the sickle shape. One base, one amino acid, a whole disease: a missense change can matter greatly, which is why its type alone never tells you how harmful it is.
The second block turns the comparison into a small classifier. It checks the length first, because a length change decides between frameshift and in-frame; otherwise it translates both versions and compares them letter by letter.
def classify(ref, alt):
if (len(alt) - len(ref)) % 3 != 0:
return "frameshift"
if len(alt) != len(ref):
return "in-frame indel"
p_ref, p_alt = Seq(ref).translate(), Seq(alt).translate()
for i, (a, b) in enumerate(zip(p_ref, p_alt), start=1):
if a != b:
kind = "nonsense" if b == "*" else "missense"
return f"{kind} at codon {i}: {a} -> {b}"
return "synonymous"
variants = {
"c.20A>T": substitute(ref, 20, "T"),
"c.19G>A": substitute(ref, 19, "A"),
"c.21G>A": substitute(ref, 21, "A"),
"c.118C>T": substitute(ref, 118, "T"),
"c.20del": ref[:19] + ref[20:],
"c.25_27del": ref[:24] + ref[27:],
}
for name, seq in variants.items():
print(f"{name:11}", classify(ref, seq))What this does
(len(alt) - len(ref)) % 3 != 0asks whether the change in length leaves a remainder when divided by 3.%gives the remainder. If it does, the frame has shifted.- If the length changed by a multiple of 3, the change is an in-frame indel.
- Otherwise both versions are translated and compared position by position.
enumerate(..., start=1)numbers the positions from 1, like HGVS. The first difference is reported as nonsense if the new letter is*, the stop symbol, and as missense otherwise. No difference at all means synonymous. variantsbuilds six versions of the sequence: four single-base changes, a one-base deletion and a three-base deletion (ref[:24] + ref[27:]drops c.25 to c.27).
Reading the output
Each line matches the table. c.20A>T and c.19G>A both hit codon 7: the first gives valine (sickle-cell haemoglobin), the second lysine, the variant known as haemoglobin C. c.21G>A changes the third base of the same codon and changes nothing, since GAG and GAA both mean glutamate. c.118C>T turns codon 40, CAG (glutamine), into the stop codon TAG. The two deletions are classified by length alone.
The classifier has clear limits. It cannot see splice variants, because a coding sequence has no introns; detecting them needs the gene's genomic sequence and the exon boundaries. It does not handle changes to the start or stop codon, which have their own consequence terms. And it says nothing about how harmful a variant is: that needs evidence such as conservation across species (Multiple alignment and conserved regions), population frequency, and clinical records.
Key point
What a coding variant does depends on the reading frame: same amino acid, a different one, an early stop, or a shifted frame. Write it in HGVS with a versioned reference, and let a tool such as the Ensembl VEP report its consequence on every transcript.
Then remember that consequence is not the same as clinical significance. A HIGH-impact label in a gene that tolerates loss may be harmless, and a single missense change, like the sickle-cell variant, can cause serious disease.
Further reading · Module 4Ensembl VEP: the web tool and its documentation. · Ensembl consequence terms: every term and its impact rating. · HGVS nomenclature: the official rules. · All reading for this course
Check your understanding
1. A deletion of 4 bases falls inside a coding exon. What type of change is it most likely to be?
2. An older paper calls the sickle-cell change Glu6Val, while HGVS writes p.Glu7Val. Why?
3. The Ensembl VEP labels a variant as HIGH impact. What can you conclude?
Up next
Project
Identify an unknown sequence