Interrogating a structure
Before a structure goes into a docking run or a training set, someone should ask it the questions in this unit: what kind of model it is, how well the data support it, which atoms are uncertain or absent, and how its numbering maps to the protein's sequence. In this lab you write the code that asks them, for the anchor structures and three newcomers: myoglobin at atomic resolution (1A6M), the Abl kinase with the cancer drug imatinib (2HYY), and the p53 tumor suppressor, both its crystallized core domain (1TSR) and AlphaFold's model of the whole protein.
Try each task before opening its solution. The solutions run as written in the repo (uv run) or in the
downloadable notebook.
Task 1: what kind of model is it?
Using Bio.PDB.MMCIF2Dict, print a table with each entry's experimental method, resolution, R (work), R-free,
and deposition date for 1UBQ, 4HHB, 7RSA, 1A6M, 1D3Z, 1EHZ, 1M17, and 1TSR. The mmCIF items are
_exptl.method, _refine.ls_d_res_high, _refine.ls_R_factor_R_work (older entries put R in
_refine.ls_R_factor_obs instead), _refine.ls_R_factor_R_free, and
_pdbx_database_status.recvd_initial_deposition_date. Which entries lack an R-free, and why? Which have no
resolution?
Solution
import numpy as np
import matplotlib.pyplot as plt
from Bio.PDB.MMCIF2Dict import MMCIF2Dict
from primer import alphafold, fetch, structure
def item(cif, key):
value = cif.get(key, ["?"])[0]
return value if value not in ("?", ".") else None
print(f"{'entry':<6} {'method':<18} {'res (Å)':>7} {'R':>6} {'R-free':>6} deposited")
for pdb_id in ["1UBQ", "4HHB", "7RSA", "1A6M", "1D3Z", "1EHZ", "1M17", "1TSR"]:
cif = MMCIF2Dict(str(fetch(pdb_id, "cif")))
r_work = item(cif, "_refine.ls_R_factor_R_work") or item(cif, "_refine.ls_R_factor_obs")
cells = [item(cif, "_refine.ls_d_res_high"), r_work, item(cif, "_refine.ls_R_factor_R_free")]
shown = [f"{float(c):.3g}" if c else "–" for c in cells]
print(f"{pdb_id:<6} {item(cif, '_exptl.method'):<18} {shown[0]:>7} {shown[1]:>6} {shown[2]:>6} "
f"{item(cif, '_pdbx_database_status.recvd_initial_deposition_date')}")
entry method res (Å) R R-free deposited 1UBQ X-RAY DIFFRACTION 1.8 0.176 – 1987-01-02 4HHB X-RAY DIFFRACTION 1.74 0.135 – 1984-03-07 7RSA X-RAY DIFFRACTION 1.26 0.15 – 1988-06-10 1A6M X-RAY DIFFRACTION 1 0.122 0.159 1998-02-26 1D3Z SOLUTION NMR – – – 1999-10-01 1EHZ X-RAY DIFFRACTION 1.93 0.233 0.253 2000-02-23 1M17 X-RAY DIFFRACTION 2.6 0.251 0.295 2002-06-17 1TSR X-RAY DIFFRACTION 2.2 0.205 – 1995-07-28
1UBQ, 4HHB, and 7RSA were deposited before R-free existed (1992), and 1TSR's depositors didn't report one. 1D3Z is an NMR ensemble, so it has no resolution and no R. Of the models with both numbers, 1A6M (1.0 Å, R/R-free 0.12/0.16) is about as good as crystal structures get, and 1M17 (2.6 Å, 0.25/0.30) is typical of a drug-complex structure: fine for the binding site's overall shape, less so for individual side-chain rotamers.
Task 2: alternate conformations in myoglobin
1A6M is oxymyoglobin at 1.0 Å, with an oxygen molecule bound to the heme iron. List every residue with alternate conformations, giving the occupancy of each conformer. Then find the two histidines next to the heme (His 64 above the oxygen, His 93 below the iron) and say which of them has alternates.
Solution
myoglobin = structure("1A6M")[0]["A"]
split = []
for residue in myoglobin:
disordered = [atom for atom in residue if atom.is_disordered()]
if residue.id[0] == " " and disordered:
occupancy = {alt: round(a.occupancy, 2) for alt, a in disordered[0].child_dict.items()}
split.append(f"{residue.get_resname()} {residue.id[1]} {occupancy}")
print(f"{len(split)} residues with alternate conformations:")
print("\n".join(split))
25 residues with alternate conformations:
GLU 4 {'A': 0.57, 'B': 0.43}
GLN 8 {'A': 0.57, 'B': 0.43}
GLN 26 {'A': 0.65, 'B': 0.35}
ARG 31 {'A': 0.42, 'B': 0.58}
GLU 41 {'A': 0.51, 'B': 0.49}
LYS 47 {'A': 0.68, 'B': 0.32}
LYS 56 {'A': 0.47, 'B': 0.53}
LEU 61 {'A': 0.66, 'B': 0.34}
LYS 63 {'A': 0.59, 'B': 0.41}
HIS 64 {'A': 0.5, 'B': 0.5}
GLN 91 {'A': 0.53, 'B': 0.47}
LYS 96 {'A': 0.55, 'B': 0.45}
GLU 109 {'A': 0.66, 'B': 0.34}
LEU 115 {'A': 0.48, 'B': 0.52}
HIS 116 {'A': 0.54, 'B': 0.46}
SER 117 {'A': 0.56, 'B': 0.44}
ARG 118 {'A': 0.48, 'B': 0.52}
ASP 126 {'A': 0.66, 'B': 0.34}
GLN 128 {'A': 0.56, 'B': 0.44}
LYS 133 {'A': 0.55, 'B': 0.45}
GLU 136 {'A': 0.57, 'B': 0.43}
PHE 138 {'A': 0.49, 'B': 0.51}
ILE 142 {'A': 0.67, 'B': 0.33}
TYR 146 {'A': 0.49, 'B': 0.51}
TYR 151 {'A': 0.5, 'B': 0.5}His 64 sits in two conformations at 50% each. It is the distal histidine, the residue that hydrogen-bonds the bound oxygen, so the crystal shows it in two positions near the ligand. His 93, which holds the iron from below, has a single position. The other split residues are scattered over the surface, mostly charged and polar side chains (lysines, glutamates, glutamines, arginines) with a few hydrophobic ones.
Myoglobin (1A6M) around the heme, with His 64 above the bound oxygen and His 93 below the iron. This viewer draws only the first alternate conformation of His 64. Open the entry in Mol* or ChimeraX to see both.
Open 1A6M in Mol*Task 3: B factors and burial
Do buried residues have lower B factors? For 1UBQ, compute each residue's mean B factor over its atoms and a simple burial measure: the number of other residues whose Cα lies within 10 Å of its Cα. Plot one against the other and report the correlation.
Solution
ubq = [r for r in structure("1UBQ")[0]["A"] if r.id[0] == " "]
ca = np.array([r["CA"].coord for r in ubq])
neighbors = (np.linalg.norm(ca[:, None] - ca[None], axis=2) < 10).sum(axis=1) - 1
mean_b = np.array([np.mean([a.bfactor for a in r]) for r in ubq])
fig, ax = plt.subplots(figsize=(5.2, 3.4))
ax.scatter(neighbors, mean_b, s=14, color="#2a78d6")
for r, n, b in zip(ubq, neighbors, mean_b):
if r.id[1] >= 73:
ax.annotate(f"{r.get_resname().title()} {r.id[1]}", (n, b), xytext=(4, 0), textcoords="offset points", fontsize=8)
ax.set_xlabel("Cα neighbors within 10 Å")
ax.set_ylabel("mean B factor (Ų)")
plt.show()
print(f"correlation: {np.corrcoef(neighbors, mean_b)[0, 1]:.2f}")
correlation: -0.69
The correlation is clearly negative (about −0.7): residues with more neighbors have lower B factors, and the tail residues 73–76, with the fewest neighbors, have the highest. Packing restrains motion and disorder, so burial is one of the best simple predictors of B factors.
Task 4: crystal B factors against NMR spread
1D3Z (NMR) and 1UBQ (X-ray) are the same protein. Superpose the ten NMR models on the Cα atoms of residues
1–70 (Bio.PDB.Superimposer), compute each residue's Cα root-mean-square fluctuation (RMSF) across the
models, and compare it with the RMSF implied by 1UBQ's Cα B factors. For an isotropic B factor the 3D
fluctuation is . Where do the two agree, and where not?
Solution
from Bio.PDB import Superimposer
nmr = structure("1D3Z")
core = range(1, 71)
reference = [nmr[0]["A"][i]["CA"] for i in core]
superimposer = Superimposer()
models = []
for model in nmr:
superimposer.set_atoms(reference, [model["A"][i]["CA"] for i in core])
rot, tran = superimposer.rotran
models.append(np.array([model["A"][i]["CA"].coord for i in range(1, 77)]) @ rot + tran)
models = np.array(models)
rmsf_nmr = np.sqrt(((models - models.mean(axis=0)) ** 2).sum(axis=-1).mean(axis=0))
b = np.array([structure("1UBQ")[0]["A"][i]["CA"].bfactor for i in range(1, 77)])
rmsf_xray = np.sqrt(3 * b / (8 * np.pi**2))
fig, ax = plt.subplots(figsize=(6.4, 3.0))
ax.plot(range(1, 77), rmsf_xray, label="from 1UBQ B factors")
ax.plot(range(1, 77), rmsf_nmr, label="1D3Z ensemble")
ax.set_yscale("log")
ax.set_xlabel("residue")
ax.set_ylabel("Cα RMSF (Å)")
ax.legend()
plt.show()
print(f"correlation over residues 1–76: {np.corrcoef(rmsf_nmr, rmsf_xray)[0, 1]:.2f}; "
f"over 1–70: {np.corrcoef(rmsf_nmr[:70], rmsf_xray[:70])[0, 1]:.2f}")
print("NMR RMSF of residues 70–76:", np.round(rmsf_nmr[69:], 2))
correlation over residues 1–76: 0.62; over 1–70: 0.28 NMR RMSF of residues 70–76: [0.14 0.23 0.34 0.68 1.88 3.87 6.58]
Both methods agree that the C-terminal tail is the loose end: the NMR models spread by more than 6 Å at Gly 76, and the crystal's B factors rise there too. In the core they disagree in scale and in detail. The NMR spread is a few hundredths to a few tenths of an ångström, while the B factors imply 0.4–0.8 Å throughout the core, because B also carries lattice disorder and model error that an NMR ensemble doesn't. Over residues 1–70 the correlation is weak: neither number measures motion alone.
Task 5: what's missing, and where
2HYY holds four copies of the Abl kinase domain with imatinib (chains A–D). For each chain, list the author
numbers of residues that are in the deposited sequence but have no coordinates (use
_pdbx_poly_seq_scheme, where auth_seq_num is "?" for unobserved residues). Do the four copies agree?
Then show what goes wrong if you number chain C's residues by their order in the coordinates.
Solution
def ranges(numbers):
"""[228, 229, 230, 275] -> '228–230, 275'"""
runs = []
for n in numbers:
if runs and n == runs[-1][-1] + 1:
runs[-1].append(n)
else:
runs.append([n])
return ", ".join(f"{r[0]}–{r[-1]}" if len(r) > 1 else str(r[0]) for r in runs)
abl = MMCIF2Dict(str(fetch("2HYY", "cif")))
scheme = list(zip(abl["_pdbx_poly_seq_scheme.pdb_strand_id"], abl["_pdbx_poly_seq_scheme.pdb_seq_num"],
abl["_pdbx_poly_seq_scheme.auth_seq_num"], abl["_pdbx_poly_seq_scheme.mon_id"]))
for chain in "ABCD":
rows = [r for r in scheme if r[0] == chain]
missing = [int(r[1]) for r in rows if r[2] == "?"]
print(f"chain {chain}: {len(rows)} residues in the sequence ({rows[0][1]}–{rows[-1][1]}), "
f"{len(missing)} without coordinates: {ranges(missing)}")
observed = [r for r in structure("2HYY")[0]["C"] if r.id[0] == " "]
naive = {i + int(observed[0].id[1]): r for i, r in enumerate(observed)} # "the n-th residue I see is number first + n"
wrong = [n for n, r in naive.items() if r.id[1] != n]
print(f"chain C: numbering by order mislabels {len(wrong)} of {len(observed)} residues, starting at {wrong[0]}")
chain A: 273 residues in the sequence (228–500), 10 without coordinates: 228–234, 275, 499–500 chain B: 273 residues in the sequence (228–500), 8 without coordinates: 228–232, 276, 499–500 chain C: 273 residues in the sequence (228–500), 11 without coordinates: 228–232, 276, 389–391, 499–500 chain D: 273 residues in the sequence (228–500), 9 without coordinates: 228–232, 276–277, 499–500 chain C: numbering by order mislabels 219 of 262 residues, starting at 276
The four copies disagree. Chain A lacks two more N-terminal residues than the others, chain C also lacks residues 389–391, and the one- or two-residue gap near 275–277 shifts from chain to chain. Residues 389–391 lie in the kinase's activation loop, a flexible segment that is ordered in some copies and invisible in another. Copies in one crystal sit in different packing environments, so their disorder differs. Numbering by order goes wrong at the first gap and stays wrong for every residue after it.
Task 6: a prediction's confidence and a crystal's construct
Load AlphaFold's model of p53 (alphafold("P04637") returns the file) and plot pLDDT (the B-factor column
of the Cα atoms) along the sequence. Shade the residues observed in the crystal structure 1TSR (chain A).
What fraction of p53 does AlphaFold predict with low confidence (pLDDT < 50), and where is it?
Solution
from Bio.PDB import PDBParser
model = PDBParser(QUIET=True).get_structure("p53", alphafold("P04637"))[0]["A"]
plddt = np.array([r["CA"].bfactor for r in model])
number = np.array([r.id[1] for r in model])
crystal = MMCIF2Dict(str(fetch("1TSR", "cif")))
seen = [int(n) for chain, n, auth in zip(crystal["_pdbx_poly_seq_scheme.pdb_strand_id"],
crystal["_pdbx_poly_seq_scheme.pdb_seq_num"],
crystal["_pdbx_poly_seq_scheme.auth_seq_num"])
if chain == "A" and auth != "?"]
fig, ax = plt.subplots(figsize=(6.4, 3.0))
ax.axvspan(min(seen), max(seen), color="#2a78d6", alpha=0.12, lw=0)
ax.plot(number, plddt, color="#333333", lw=1.5)
for level in (50, 70, 90):
ax.axhline(level, color="#dddddd", lw=0.8, zorder=0)
ax.text(min(seen) + 3, 8, f"in 1TSR: {min(seen)}–{max(seen)}", fontsize=9, color="#1c5cab")
ax.set_xlabel("p53 residue")
ax.set_ylabel("pLDDT")
ax.set_ylim(0, 100)
plt.show()
low = plddt < 50
print(f"{low.mean():.0%} of {len(plddt)} residues have pLDDT < 50; "
f"mean pLDDT {plddt[(number >= 94) & (number <= 289)].mean():.0f} inside 94–289, "
f"{plddt[(number < 94) | (number > 312)].mean():.0f} outside the crystallized construct")
30% of 393 residues have pLDDT < 50; mean pLDDT 95 inside 94–289, 55 outside the crystallized construct
The confident region and the crystallized region coincide: the DNA-binding domain (about 94–292) and, to the right, the tetramerization domain near 325–355. Most of the rest, the N-terminal transactivation region and the C-terminal tail, has pLDDT below 50. Those regions are intrinsically disordered, which is also why the crystallographers left them out of the construct: proteins with long disordered tails rarely crystallize. The short confident stretch near residues 20–25 is a helix that forms when p53 binds its regulator MDM2.
In a viewer
Open each of these in Mol* (the links under the 3D views) or ChimeraX and look for what you computed.
- 1A6M: show His 64 as sticks and find both conformations. In ChimeraX,
open 1a6mandshow :64draw both alternates. - 1UBQ colored by B factor (ChimeraX
color bfactor; Mol* color theme "Uncertainty/Disorder"): the dark tail you plotted in task 3. - 1D3Z with all models shown: the splayed C-terminal tail from task 4.
- AlphaFold's p53 colored by confidence (ChimeraX
color bfactor palette alphafold), next to 1TSR: the crystal covers the blue domain.
AlphaFold's p53 model by pLDDT, for comparison with your plot in task 6.
Open AF-P04637 in Mol*Self-check
You need a high-quality model of ubiquitin's C-terminal tail (residues 71–76) for docking to an enzyme. Based on tasks 3 and 4, how much should you trust any single model of that tail, and what would you do instead?
Reasoning
Very little. The crystal's B factors there are 25–36 Ų (rms displacements approaching 1 Å) and the NMR models fan out by several ångströms at Gly 76: the tail adopts many conformations in solution, and any one model is a snapshot or a compromise. Instead, treat the tail as flexible: dock with several conformations (the NMR models, or ones generated by simulation), or use a structure of ubiquitin bound to a similar enzyme, where the tail is held in place.
A dataset filter keeps "all structures at 2.0 Å or better with R-free under 0.25." Which of this lab's entries would it drop, and which useful structure would it exclude for a reason that has nothing to do with quality?
Reasoning
It drops 1M17 (2.6 Å) and 1TSR (2.2 Å), and 1EHZ narrowly (R-free 0.253). It also drops 1UBQ, 4HHB, and 7RSA, whose R-free is missing because they predate it, even though they are good structures, and 1D3Z, which as an NMR ensemble has neither number. A filter should treat "not reported" separately from "bad", for example by falling back to R and the deposition year for old entries and to NMR-specific criteria for ensembles.
In task 5, chain C of 2HYY lacks residues 389–391, while chains A, B, and D have them. Give two reasons this could happen, and say which interpretation the other three chains support.
Reasoning
The activation loop could be genuinely flexible, ordered only when crystal contacts or local packing happen to hold it, or chain C's environment in the crystal could leave it free while the others are pinned. Data quality in that part of the map could also differ between copies. The three ordered copies show that the loop can adopt a defined conformation in this crystal, so its absence in chain C is about that copy's environment or local disorder, not about the loop's sequence or chemistry.
Someone uses AlphaFold's p53 model to measure the distance between residues 10 and 380 and reports "about 60 Å apart." What's wrong with the measurement?
Reasoning
Both residues are in low-confidence (pLDDT < 50) disordered regions. AlphaFold places such regions as extended, arbitrary loops; their coordinates are not a prediction of where the residues are, and in reality the distance fluctuates over a wide range. A predicted aligned error (PAE) map would also show that the relative position of these regions is undetermined. The meaningful statement is that the termini are disordered, with no fixed distance between them.
Task 2 found His 64 in two conformations at 50% each. Could both conformations exist in one myoglobin molecule at the same instant? What do the occupancies say about the crystal?
Reasoning
No: the two positions are alternatives for the same atoms, so one molecule has one or the other at any moment (and the two copies overlap in space, as the bond-guessing exercise in lesson 6.4 showed). The occupancies say that, averaged over all the molecules in the crystal and the duration of the measurement, about half had His 64 in each position. Whether individual molecules switch back and forth or are stuck in one state can't be told from this one dataset.