Interactions in real structures
Suppose a predicted protein looks convincing. Its cartoon is compact and its strands line up. That picture cannot tell us whether the underlying atoms make plausible contacts. We need measurements that can fail, then a way to understand what each failure means.
We will develop those measurements on ubiquitin (1UBQ), compare disulfides in crambin (1CRN) and hemoglobin (4HHB), and deliberately damage ubiquitin in two ways. One change rotates a buried side chain; the other reflects the entire molecule. Predict which detectors will notice each change.
Use Python with Biopython, NumPy, and Matplotlib, or read the saved cell outputs. The notebook download
includes the primer helper. Run the solutions in order; later tasks use arrays and functions created
earlier. These are small inspectable detectors, with explicit simplifications, rather than a full
structure-validation package.
Task 1: propose hydrogen-bond candidates
Begin with a generous hypothesis: a donor and acceptor within 3.5 Å might form a hydrogen bond. List the candidate pairs in chain A of 1UBQ, then count how many are backbone N···O pairs. Exclude pairs within the same residue and backbone pairs from adjacent residues, whose proximity follows from local covalent geometry.
Use the group assignments from lesson 1.4. The solution treats both histidine nitrogens as potential donors or acceptors because it has not chosen a protonation state or neutral tautomer, the arrangement of the proton between the ring nitrogens. That broad assignment will need refinement before any individual histidine interaction is accepted.
Solution
import numpy as np
from collections import Counter
from primer import structure
SIDE_DONORS = {"SER": ["OG"], "THR": ["OG1"], "TYR": ["OH"], "ASN": ["ND2"], "GLN": ["NE2"], "HIS": ["ND1", "NE2"],
"LYS": ["NZ"], "ARG": ["NE", "NH1", "NH2"], "TRP": ["NE1"]}
SIDE_ACCEPTORS = {"ASP": ["OD1", "OD2"], "GLU": ["OE1", "OE2"], "SER": ["OG"], "THR": ["OG1"], "TYR": ["OH"],
"ASN": ["OD1"], "GLN": ["OE1"], "HIS": ["ND1", "NE2"], "MET": ["SD"]}
def donors(res):
backbone = [res["N"]] if res.get_resname() != "PRO" and "N" in res else []
return backbone + [res[a] for a in SIDE_DONORS.get(res.get_resname(), []) if a in res]
def acceptors(res):
backbone = [res[a] for a in ("O", "OXT") if a in res]
return backbone + [res[a] for a in SIDE_ACCEPTORS.get(res.get_resname(), []) if a in res]
def hbonds_by_distance(chain, cutoff=3.5):
residues = [r for r in chain if r.id[0] == " "]
found = []
for rd in residues:
for d in donors(rd):
for ra in residues:
for a in acceptors(ra):
same_peptide = d.get_id() == "N" and a.get_id() == "O" and abs(rd.id[1] - ra.id[1]) < 2
if ra is rd or same_peptide:
continue
if d - a <= cutoff:
found.append((rd, d, ra, a, d - a))
return found
ubq = structure("1UBQ")[0]["A"]
pairs = hbonds_by_distance(ubq)
backbone = [p for p in pairs if p[1].get_id() == "N" and p[3].get_id() == "O"]
print(len(pairs), "donor–acceptor pairs within 3.5 Å;", len(backbone), "backbone N···O")
112 donor–acceptor pairs within 3.5 Å; 81 backbone N···O
The output is a candidate count. A larger count does not by itself mean a better structure. We have not yet asked which direction a donor hydrogen points, and some side-chain assignments depend on hydrogens that the file does not contain.
Task 2: ask whether the hydrogen points there
For ordinary backbone amides, estimate the missing hydrogen from local geometry. Place it about 1.01 Å from N, in the peptide plane, pointing away from the previous carbonyl carbon and the current Cα. Skip proline and the first residue, for which this construction is inappropriate.
Keep candidates with H···O distance at most 2.5 Å and N–H···O angle at least 120°. Predict whether this makes the list shorter or longer, then count the residue offsets .
Solution
def unit(v):
return v / np.linalg.norm(v)
def backbone_hydrogens(chain):
"""Place each backbone amide H (no H on proline or on the first residue)."""
residues = [r for r in chain if r.id[0] == " "]
h = {}
for prev, r in zip(residues, residues[1:]):
if r.get_resname() != "PRO":
n = r["N"].coord
h[r.id[1]] = n + 1.01 * unit(unit(n - prev["C"].coord) + unit(n - r["CA"].coord))
return h
H = backbone_hydrogens(ubq)
geometric = []
for rd, d, ra, a, dist in backbone:
h = H.get(rd.id[1])
if h is None:
continue
angle = np.degrees(np.arccos(np.dot(unit(d.coord - h), unit(a.coord - h))))
if np.linalg.norm(a.coord - h) <= 2.5 and angle >= 120:
geometric.append((rd.id[1], ra.id[1]))
print(len(geometric), "backbone hydrogen bonds pass the geometric test")
print("most common offsets (donor − acceptor):", Counter(i - j for i, j in geometric).most_common(5))
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(4.2, 4.2))
ax.scatter([j for i, j in geometric], [i for i, j in geometric], s=14, color="#2a78d6")
ax.plot([1, 76], [1, 76], color="#dddddd", lw=1)
ax.set_xlabel("acceptor residue (C=O)")
ax.set_ylabel("donor residue (N–H)")
ax.set_aspect("equal")
plt.show()
44 backbone hydrogen bonds pass the geometric test most common offsets (donor − acceptor): [(3, 11), (4, 10), (-61, 2), (-28, 2), (63, 2)]
The angular test removes many distance-only candidates. A run of offset +4 contacts corresponds to the repeating carbonyl-to-N–H pattern of an α-helix; offsets near +3 can arise in tighter turns. Contacts far from the diagonal join distant parts of the sequence. The hydrogen positions are constructed from ideal geometry, so this is a better geometric hypothesis, not a direct observation of the hydrogens.
Task 3: find close opposite charges
Assume near-neutral pH and the conventional charged states of Lys, Arg, Asp, and Glu. Search for positive nitrogens within 4 Å of negative oxygens. Report each residue pair once, using its closest qualifying atom pair. Why would counting every atom pair exaggerate the number of interacting residues?
Solution
POSITIVE = {"LYS": ["NZ"], "ARG": ["NE", "NH1", "NH2"]}
NEGATIVE = {"ASP": ["OD1", "OD2"], "GLU": ["OE1", "OE2"]}
def salt_bridges(chain, cutoff=4.0):
plus = [(r, r[a]) for r in chain for a in POSITIVE.get(r.get_resname(), []) if a in r]
minus = [(r, r[a]) for r in chain for a in NEGATIVE.get(r.get_resname(), []) if a in r]
best = {}
for rp, p in plus:
for rm, m in minus:
key = (f"{rp.get_resname()} {rp.id[1]}", f"{rm.get_resname()} {rm.id[1]}")
if p - m <= cutoff and (key not in best or p - m < best[key][0]):
best[key] = (p - m, p.get_id(), m.get_id())
return best
for (plus, minus), (dist, a, b) in sorted(salt_bridges(ubq).items()):
print(f"{plus:>7} {a:<3} – {minus:>7} {b:<3} {dist:.2f} Å")
ARG 54 NH1 – ASP 58 OD1 3.88 Å LYS 11 NZ – GLU 34 OE2 3.35 Å LYS 27 NZ – ASP 52 OD2 2.90 Å
One side chain has several atoms that can approach the other, so a single residue pair can contribute multiple short distances. Reporting the closest distance avoids presenting these as independent residue interactions. The resulting candidates still rely on the chosen protonation states.
Inspect the helix contacts from task 2 and the ion-pair candidates from task 3. In the final view, find Leu 67 packed among nearby residues. Imagine turning that side chain without moving its neighbors; task 5 will do exactly this and measure the result.
Open 1UBQ in Mol*Task 4: count cysteines, then find their partners
A disulfide search should examine sulfur positions rather than assume that cysteines pair. Find every pair of cysteine SG atoms within 2.5 Å in each whole model. Use all chains so that a possible interchain bond is not excluded in advance. Compare crambin and hemoglobin.
Solution
from itertools import combinations
def disulfides(model):
cys = [r for r in model.get_residues() if r.get_resname() == "CYS" and "SG" in r]
pairs = [(a, b, a["SG"] - b["SG"]) for a, b in combinations(cys, 2) if a["SG"] - b["SG"] < 2.5]
return cys, pairs
for pdb_id in ("1CRN", "4HHB"):
cys, pairs = disulfides(structure(pdb_id)[0])
links = ", ".join(f"{a.get_parent().id}{a.id[1]}–{b.get_parent().id}{b.id[1]} ({d:.2f} Å)" for a, b, d in pairs)
print(f"{pdb_id}: {len(cys)} cysteines, {len(pairs)} disulfides {links}")
1CRN: 6 cysteines, 3 disulfides A3–A40 (2.00 Å), A4–A32 (2.03 Å), A16–A26 (2.05 Å) 4HHB: 6 cysteines, 0 disulfides
Crambin has six cysteines paired into three disulfides. Hemoglobin has six cysteines and no such pairs in this structure. Its location inside red blood cells is consistent with unlinked thiols in a reducing cytosol. The contrast tests why “contains cysteine” and “contains disulfides” require different queries of a structure.
Trace crambin's three sulfur links and the lengths of chain between their endpoints. Each link adds a covalent constraint that remains even if many noncovalent contacts are disrupted.
Open 1CRN in Mol*Task 5: damage the packing
Build a deliberately simple steric detector. For each heavy-atom pair, subtract the distance from the sum of van der Waals radii. Flag overlaps greater than 0.5 Å. Exclude pairs within four bonds of one another, whose geometry belongs to the covalent model.
The solution also excludes every pair made of N/O atoms to avoid treating ordinary polar contacts as clashes. This is a broad shortcut: it will miss genuinely bad N/O overlaps. Keep that blind spot in mind when interpreting a zero count.
Run the detector on 1UBQ, then rotate Leu 67's side chain by 120° and 240° around its Cα–Cβ bond. Keep the original bond graph when testing the rotated coordinates; otherwise, a new collision might be incorrectly reclassified as a bond and excluded from the check.
For a point offset from an axis with unit direction , use Rodrigues' rotation formula:
Solution
VDW = {"C": 1.7, "N": 1.55, "O": 1.52, "S": 1.8}
COVALENT = {"C": 0.76, "N": 0.71, "O": 0.66, "S": 1.05}
atoms = [a for a in ubq.get_atoms() if a.get_parent().id[0] == " "]
element = [a.element for a in atoms]
label = [f"{a.get_parent().get_resname()}{a.get_parent().id[1]}:{a.get_id()}" for a in atoms]
xyz0 = np.array([a.coord for a in atoms])
def within_four_bonds(xyz):
d = np.linalg.norm(xyz[:, None] - xyz[None], axis=-1)
r = np.array([COVALENT[e] for e in element])
bond = ((d < r[:, None] + r[None] + 0.4) & (d > 0)).astype(int)
near = bond.copy()
for _ in range(3):
near = ((near + near @ bond) > 0).astype(int)
np.fill_diagonal(near, 1)
return near.astype(bool)
BONDED = within_four_bonds(xyz0) # covalent structure doesn't change when we rotate a side chain
POLAR = np.array([e in "NO" for e in element])
def clashes(xyz, threshold=0.5):
d = np.linalg.norm(xyz[:, None] - xyz[None], axis=-1)
v = np.array([VDW[e] for e in element])
overlap = v[:, None] + v[None] - d
flag = np.triu(~BONDED & (overlap > threshold) & ~(POLAR[:, None] & POLAR[None]), 1)
return [(label[i], label[j], round(float(overlap[i, j]), 2)) for i, j in zip(*np.nonzero(flag))]
def rotate_about(xyz, idx, a, b, degrees):
k = unit(b - a)
t = np.radians(degrees)
p = xyz[idx] - a
out = xyz.copy()
out[idx] = a + p * np.cos(t) + np.cross(k, p) * np.sin(t) + np.outer(p @ k, k) * (1 - np.cos(t))
return out
print("deposited 1UBQ:", clashes(xyz0) or "no clashes")
leu67 = ubq[67]
side = [i for i, a in enumerate(atoms) if a.get_parent() is leu67 and a.get_id() not in ("N", "CA", "C", "O", "CB")]
for angle in (120, 240):
moved = rotate_about(xyz0, side, leu67["CA"].coord, leu67["CB"].coord, angle)
found = clashes(moved)
print(f"Leu 67 χ1 rotated {angle}°: {len(found)} clashes, worst {max(found, key=lambda c: c[2]) if found else None}")
deposited 1UBQ: no clashes
Leu 67 χ1 rotated 120°: 5 clashes, worst ('VAL5:CA', 'LEU67:CD2', 1.02)
Leu 67 χ1 rotated 240°: 5 clashes, worst ('LEU67:CD2', 'HIS68:N', 0.72)The original model passes this limited check, while the rotations introduce clashes. The side chain has kept its internal covalent geometry but moved into space occupied by other atoms. Common side-chain conformations, called rotamers, are therefore candidates to test in context; a favorable isolated torsion does not guarantee that the surrounding protein leaves room for it.
Try another leucine, keeping its identity explicit in the code. If a rotation produces fewer clashes, inspect which neighbors are absent or farther away. Passing this detector shows only that its particular severe overlaps were not found. It does not establish that the new rotamer has a favorable overall free energy.
Task 6: make a change that distances cannot see
Negate every x coordinate to reflect ubiquitin through a plane. Predict the effect on the salt-bridge distance, the clash count, and the signed chirality volumes before running this cell.
Solution
def volume(n, ca, c, cb):
return float(np.dot(n - ca, np.cross(c - ca, cb - ca)))
index = {(a.get_parent().id[1], a.get_id()): i for i, a in enumerate(atoms)}
def volumes(xyz):
return [volume(*(xyz[index[(r, name)]] for name in ("N", "CA", "C", "CB")))
for r in sorted({k[0] for k in index}) if (r, "CB") in index]
mirror = xyz0 * np.array([-1, 1, 1])
v0, v1 = volumes(xyz0), volumes(mirror)
print(f"original: {min(v0):+.2f} to {max(v0):+.2f} ų mirrored: {min(v1):+.2f} to {max(v1):+.2f} ų")
nz, oe = index[(11, "NZ")], index[(34, "OE2")]
print(f"Lys 11 NZ – Glu 34 OE2: {np.linalg.norm(xyz0[nz] - xyz0[oe]):.2f} Å before, {np.linalg.norm(mirror[nz] - mirror[oe]):.2f} Å after")
print("clashes after mirroring:", len(clashes(mirror)))
original: +1.93 to +2.87 ų mirrored: -2.87 to -1.93 ų Lys 11 NZ – Glu 34 OE2: 3.35 Å before, 3.35 Å after clashes after mirroring: 0
The measured distance and clash count stay the same. Every signed volume reverses. Reflection is an exact way to expose the limitation of a distance-only check: it preserves internal pair geometry while reversing the molecule's handedness. To distinguish the ordinary protein from this mirror version, a validator needs stereochemical information.
Self-check
An N···O pair passes the distance test and fails the hydrogen-angle test. What can explain its short distance without making it a hydrogen bond?
Reasoning
Nearby parts of the connected chain can place the atoms close together while the N–H points elsewhere. Another local interaction may also determine their positions. Distance narrows the candidates; donor orientation and chemical state determine whether the proposed hydrogen bond is plausible.
Replace Lys 11 in the observed Lys 11–Glu 34 pair with arginine, then with methionine. Which interaction would you try to recover in each mutant, and what would you avoid concluding from charge alone?
Reasoning
Arginine normally retains positive charge, so an ion pair remains plausible if its longer, differently shaped group can fit. Methionine removes that positive group, so the same salt bridge cannot survive. Neither fact fixes the stability change: packing, water, side-chain flexibility, and alternative contacts can differ. The structure suggests calculations or experiments, not a universal kcal/mol value.
Mutating one cysteine of a disulfide to serine removes the cross-link. Why might the protein become less stable even if its folded backbone initially looks unchanged?
Reasoning
The unfolded chain gains access to conformations that the cross-link previously excluded, increasing its entropic advantage. The remaining cysteine may stay a free thiol or react with another suitable partner under oxidizing conditions. Folded coordinates alone do not describe these changes to the unfolded ensemble or chemical behavior.
A model has no clashes under task 5 and correct chirality, but few backbone hydrogen bonds. Give a possible explanation and a reason not to diagnose an error from the count alone.
Reasoning
Its backbone may avoid overlaps while orienting donors poorly, so expected helices or sheets fail to form their usual contacts. But a protein with different secondary structure or extensive disorder may also have fewer such bonds. Compare equivalent regions, inspect geometry and missing atoms, and use the experimental context. Also remember that the clash detector ignores every N/O pair.
Someone mirrors both a protein and its bound ligand and gets exactly the same pairwise interaction score. Then they mirror only the protein and expect the score to stay unchanged. Which expectation is justified, and why?
Reasoning
Mirroring the entire complex preserves all internal and intermolecular distances, so a distance-only score remains identical. Mirroring only the protein generally changes its distances to the unchanged ligand, disrupting the fit. The physical system being transformed must include the partners whose interactions are being scored.