Lesson 3 of 9
Module 7 · From genes to function
A protein works because of its shape. Learn the four levels of structure, how structures are measured and judged by resolution, and open a real structure file in Python to count, measure and read it.
Why shape matters
A protein's sequence, the subject of Protein families, domains and motifs, is only the start. To do its job, the chain must fold into a precise three-dimensional shape: an enzyme's pocket must fit its substrate, and a channel must open a path through the membrane. When folding goes wrong, the protein is usually inactive, and misfolded proteins can be harmful. The commonest cystic fibrosis variant, F508del, which you met in Module 2, removes a single amino acid; the CFTR protein then misfolds and most of it is destroyed before it reaches the cell surface.
Where does the shape come from? For many small proteins, the sequence alone is enough: unfolded in a test tube and then returned to normal conditions, the chain folds back into its working shape by itself. This observation, made with the enzyme ribonuclease by Christian Anfinsen in the 1950s and 1960s, is the reason predicting structure from sequence is possible at all. In the crowded cell, larger proteins often get help from chaperones, proteins that stop a chain sticking to itself or to others while it folds, but the information about the final shape is still in the sequence.
This lesson covers how structure is described, how it is measured, what a structure file contains, and how to read one in Python. The code needs Biopython: run !pip install biopython first in Colab.
Four levels of structure
Protein structure is described at four levels, each built on the one before:
- Primary structure is the amino acid sequence, read from the N-terminus (the start, with a free amino group) to the C-terminus (the end, with a free carboxyl group). It follows directly from the coding sequence of the gene.
- Secondary structure is the regular local shapes formed when the backbone, the repeating chain of atoms shared by all amino acids, makes hydrogen bonds with itself. The two main kinds are the alpha helix, a right-handed coil with about 3.6 residues per turn, and the beta strand, a stretched segment that lines up beside other strands to form a beta sheet. The parts in between are called loops or turns.
- Tertiary structure is the full 3D shape of one chain: how its helices, strands and loops pack together. Water-avoiding (hydrophobic) side chains usually end up buried in the core.
- A domain, the unit you met in Protein families, domains and motifs, is a unit of tertiary structure: a part of the chain that folds compactly on its own. A multi-domain protein such as CFTR has several such units, joined by linkers.
- Quaternary structure is how several chains come together into one working unit. Haemoglobin, for example, is made of four chains: two alpha and two beta.
How to read this figure
Read left to right. The first card is a sequence of one-letter amino acid codes. The second shows the two common local shapes: a coil for a helix and a broad arrow for a strand, drawn the way most structure viewers draw them, with the arrow pointing towards the C-terminus. The third shows these shapes packed into one chain, and the fourth shows four chains fitted together, two of each kind, like haemoglobin.
The levels also show where a sequence change does its damage. A substitution on the surface of a protein, such as one charged residue for another, often changes little. The same kind of change in the buried core, putting a charged or bulky residue where a small hydrophobic one belongs, can stop the chain from folding at all. So when you look up a variant in a structure, the first question is simple: is this residue buried or exposed?
How structures are measured
Three experimental methods produce almost all the structures in the Protein Data Bank (PDB), the single worldwide archive of experimentally determined structures, which now holds more than 200,000 entries.
| Method | What is measured | Strengths | Limits |
|---|---|---|---|
| X-ray crystallography | How X-rays scatter off a crystal of the protein | Often very fine detail; the source of most PDB entries | The protein must form crystals; flexible parts may be invisible |
| NMR spectroscopy | How atomic nuclei respond in a strong magnet, with the protein in solution | No crystal needed; shows movement | Mostly small proteins; gives a set of models, not one |
| Cryo-electron microscopy (cryo-EM) | Electron images of many frozen copies of the molecule, averaged | Large complexes and membrane proteins; no crystal needed | Very small proteins are hard; detail can vary across the map |
How to read this table
Read across each row: the method, what it actually records, what it is good at, and where it struggles. None of the methods photographs a protein directly. Each records indirect data, and scientists build an atomic model, a set of atom positions, that best explains that data. The model is an interpretation, and its quality depends on the data behind it.
The table also explains a common surprise when you open a structure: parts of the protein are missing. In X-ray and cryo-EM structures, flexible loops and disordered regions, like the CFTR R region of Protein families, domains and motifs, often leave too little signal to place, so their residues are simply absent from the model. Many entries also cover only a fragment of the protein, because the whole thing would not crystallise. Before relying on a structure for a question about a particular residue, check that the residue is actually in the model.
For X-ray and cryo-EM, quality is summed up by the resolution, given in ångströms (Å). One ångström is a ten-millionth of a millimetre, roughly the size of an atom. Smaller numbers mean finer detail. At around 1.5 to 2 Å, the shapes of side chains are clear; at 3 Å, the path of the chain and most side chains can be traced; beyond about 4 Å, side-chain positions are largely guesswork. NMR structures have no single resolution number; their uncertainty shows in how much the models in the set differ from each other. Cryo-EM has improved enormously in the last decade and now often reaches better than 3 Å.
On real data, you often have a choice. Searching the PDB for a well-studied human protein can return dozens of entries: different fragments, with and without a bound drug, from different methods and decades. A sensible way to choose is to ask, in order, which entries cover the part you care about, which are in the state you care about (for example, with the natural ligand bound), and among those, which has the best resolution and validation. The "best" structure depends on the question.
Alongside measured structures, there are now predicted ones. AlphaFold, an AI system, predicts a structure from sequence, and the AlphaFold Protein Structure Database (The main databases: sequences, genomes, proteins, structures) holds over 200 million such predictions. Each residue carries a confidence score called pLDDT, from 0 to 100. Older methods such as homology modelling, which builds a model on the known structure of a related protein, work on the same principle that similar sequences fold alike. Module 8 returns to AI structure prediction.
Go deeper: resolution is not the whole story: R-free
Two X-ray structures at the same resolution can differ in quality. Crystallographers therefore also report R-work and R-free. R-work measures how well the model explains the diffraction data used to build it. R-free measures the same thing on a small share of the data, usually about 5 to 10%, that was set aside and never used for fitting.
This is the same idea as a test set in machine learning, and it was introduced for the same reason: a model can be adjusted until it fits its own data very well while getting worse as a description of reality. A common rule of thumb is that R-free should be roughly a tenth of the resolution, so around 0.20 at 2 Å. A large gap between R-work and R-free is a warning of overfitting. The PDB's validation report for each entry shows these numbers next to other checks.
What a PDB file holds
You met the PDB format in File formats you will meet: FASTA, GenBank, GFF, VCF, PDB: one line per atom, with its x, y and z coordinates in ångströms. A file also holds a header with the method, resolution and title; the full sequence that was studied; and, in many files, records listing the helices and strands. Each atom line also carries a B-factor, a measure of how much that atom's position is blurred by movement or disorder. Large structures no longer fit the old PDB layout, so the archive's standard format is now mmCIF, which holds the same information in a more flexible form. Biopython can read both.
B-factors are useful to read alongside the structure. Atoms in the packed core usually have low B-factors; atoms at the tips of surface side chains and in loops have higher ones. A high B-factor does not mean the position is wrong, only that it is less certain, and it is one reason the key point below warns against trusting exact distances between flexible atoms. Some files also contain alternate locations: two or more positions for the same atom, each with an occupancy, the share of copies in the crystal that take that position. Biopython keeps them, and by default gives you the one with the highest occupancy.
The example is ubiquitin, a small protein of 76 amino acids found in all animals, plants and fungi. Cells attach chains of ubiquitin to other proteins as a label. The chains are linked through particular lysines: chains joined through lysine 48 usually mark a protein for destruction by the proteasome, while chains joined through lysine 63 are mostly used for signalling, for example in DNA repair. Entry 1UBQ is a classic X-ray structure of human ubiquitin.
import urllib.request
from Bio.PDB import PDBParser
urllib.request.urlretrieve("https://files.rcsb.org/download/1UBQ.pdb", "1UBQ.pdb")
structure = PDBParser(QUIET=True).get_structure("1UBQ", "1UBQ.pdb")
print(structure.header["name"])
print(structure.header["structure_method"], structure.header["resolution"], "Å")What this does
urlretrievedownloads the PDB file for entry 1UBQ from the RCSB PDB website and saves it as1UBQ.pdbnext to your notebook.PDBParser(QUIET=True)makes a reader for PDB files;QUIET=Truehides warnings about minor oddities that many older files contain.get_structurereads the file into a structure object. The first argument is just a label of your choice.structure.headeris a dictionary of facts from the top of the file. The code prints the title, the experimental method and the resolution.
Reading the output
The first line is the entry's title, which Biopython prints in lower case. The second says the structure was solved by X-ray diffraction, meaning X-ray crystallography, at a resolution of 1.8 Å. That is fine enough to see the shape of every side chain clearly.
Biopython organises a structure as a hierarchy: a structure holds one or more models (X-ray files usually have one; NMR files have several), each model holds chains, each chain holds residues, and each residue holds atoms.
model = structure[0] # the first (here, only) model chain = model["A"] residues = [r for r in chain if r.id[0] == " "] # amino acids only, no water waters = [r for r in chain if r.id[0] == "W"] atoms = [a for r in residues for a in r] print(len(model), "chain;", len(residues), "residues;", len(atoms), "protein atoms;", len(waters), "waters") print(residues[0].get_resname(), residues[-1].get_resname()) k48 = chain[48]["NZ"] # side-chain nitrogen of lysine 48 k63 = chain[63]["NZ"] # and of lysine 63 print(chain[48].get_resname(), chain[63].get_resname(), round(k48 - k63, 1), "Å apart")
What this does
structure[0]is the first model andmodel["A"]is chain A.- Every residue has an id whose first part says what it is: a blank,
" ", for an ordinary amino acid and"W"for a water molecule. The two list comprehensions sort them into amino acids and waters. atomscollects every atom of every amino acid.len(model)counts the chains in the model.chain[48]picks residue number 48, and["NZ"]picks its atom named NZ, the nitrogen at the tip of a lysine side chain, where ubiquitin chains are attached.- Subtracting one atom from another,
k48 - k63, is a Biopython shortcut that gives the straight-line distance between them in ångströms.
Reading the output
- The file holds one chain of 76 amino acids, built from 602 atoms, plus 58 water molecules that were seen in the crystal. Hydrogen atoms are not included: X-rays barely see them at this resolution, and many files leave them out.
- The chain begins with methionine (MET) and ends with glycine (GLY). That final glycine, residue 76, is the one attached to other proteins.
- Residues 48 and 63 are both lysines (LYS), as expected, and the tips of their side chains are 19.8 Å apart, on different faces of the protein. Lysine side chains are flexible, so this exact figure applies to this crystal.
Worked example · a distance from coordinates
The 19.8 Å came from the x, y and z coordinates on the two atom lines. Here they are, from the 1UBQ file, in ångströms.
K63 NZ x 17.884 y 26.544 z 1.075
differences: 0.444, 1.889, 19.752
squared: 0.197 + 3.568 + 390.14 = 393.91
√393.91 ≈ 19.8 Å
Step by step. Distance in 3D follows Pythagoras's rule. Subtract one atom's x from the other's, then the same for y and z. Square each difference so that the signs do not matter, add the three squares, and take the square root. Almost all the separation here is along z: the two atoms sit at nearly the same x and y but about 20 Å apart in the third direction.
What the answer means. Biopython did exactly this sum. Nearly every structural measurement, from whether two residues touch (a typical cut-off is about 4 Å) to how far a variant lies from a binding site, starts with distances like this one. A distance of 20 Å, about five or six atoms' widths, tells you that these two lysines are on opposite sides of a small protein.
The 1UBQ structure was published by Vijay-Kumar, Bugg and Cook in 1987 in the Journal of Molecular Biology, under the same title Biopython printed. The archive itself is run by the worldwide PDB partnership, described in Berman, Henrick and Nakamura 2003, Nature Structural Biology. When you use a structure, cite both the entry's ID and its primary paper, as the PDB asks. Remember that the deposited model is one interpretation of the data. Some old entries have since been re-refined with better methods, and the coordinates in the file reflect the software and choices of their time.
Secondary structure in the file
Many PDB files list their helices and strands near the top, in lines starting HELIX and SHEET. The columns are fixed, so a little slicing reads them.
for line in open("1UBQ.pdb"):
if line.startswith("HELIX"):
print("helix ", line[21:25].strip(), "to", line[33:37].strip())
elif line.startswith("SHEET"):
print("strand", line[22:26].strip(), "to", line[33:37].strip())What this does
- The loop reads the downloaded file line by line, as plain text.
- For each HELIX or SHEET line,
line[21:25]and similar slices pick out the residue numbers where the element starts and ends. In the PDB format each piece of information sits in fixed columns, and the two record types put their numbers in slightly different places. .strip()removes the spaces that pad each number to its column width.
Reading the output
Ubiquitin has one main helix, residues 23 to 34, and a short one at 56 to 59; the file classes this second one as a 310 helix, a tighter coil than an alpha helix. It has five strands, which together form one sheet. The strands are listed in the order they sit side by side in the sheet, not in sequence order: strand 10–17 lies next to 1–7, which lies next to 64–72, and so on. Residues far apart in the sequence are neighbours in space, which is what a tertiary fold means. The figure maps this along the chain.
Not every file has these lines. Some entries leave them out, and files of predicted structures often lack them too. The usual way to get secondary structure from any set of coordinates is a program called DSSP, which finds the backbone hydrogen bonds itself and assigns each residue to a helix, strand or loop. Assignments from different programs can differ by a residue or two at the ends of each element, so treat the exact start and end numbers as approximate.
How to read this figure
The line is the chain from residue 1 on the left to 76 on the right. Arrows are strands, pointing towards the C-terminus; coils are helices; the plain line between them is loops. The red marks show the two lysines used for chain building and the final glycine. Notice that lysine 48 sits at the start of a short strand and lysine 63 in a loop just before the last strand: both are on the surface, where enzymes can reach them.
Key point
A structure is a model built to fit experimental data. Always check how it was made and at what resolution before you trust fine details such as exact distances.
A second example: two structures of the same enzyme show a drug 3.2 Å from a key residue in one and 4.5 Å in the other. If the first was solved at 1.6 Å and the second at 3.8 Å, the first measurement deserves far more weight, because at 3.8 Å the side-chain positions themselves are uncertain by about that much.
Further reading · Module 7PDB-101: guide to understanding PDB data, including resolution. · PDB-101: methods for determining structure. · The 1UBQ entry at RCSB PDB. · The Biopython tutorial: Bio.PDB. · AlphaFold DB: frequently asked questions. · All reading for this course
Check your understanding
1. Two X-ray structures of the same protein are available, at 1.7 Å and at 3.9 Å resolution. You want to know exactly how a side chain touches a drug. Which should you use?
2. In the 1UBQ sheet, strand 1–7 lies beside strand 64–72. What does this show?
3. An NMR entry contains 20 models of the same protein. What is the best way to read this?
Up next
Lesson 4
Pathways and enrichment analysis