Degrees of freedom
A PDB file stores three coordinates per atom: 1,806 numbers for ubiquitin's 602 protein atoms. Almost none of them are free. Chemistry pins bond lengths and angles, which leaves the torsion angles, and structure prediction, conformational sampling, and design all search over those. Below you'll measure how pinned the rest really is, compute the torsions yourself, and then rebuild ubiquitin from them and watch tiny errors grow into a 4 Å miss.
The backbone as a chain of rigid plates
A polypeptide chain may be viewed as an alternating sequence of fixed "spacer" components, –CO–NH–, called peptide groups, and of variable components –HCRj–, where Rj is a side chain (the carbon atom is called an α-carbon to distinguish it from the carbon in the peptide group). The polypeptide has a backbone of the type (CαCN)n, and the residue sequence R1R2R3… completely describes it. This description is called the primary structure.
To describe the spatial configuration of the molecule, we begin by noting that the C–N bond, referred to as the peptide bond, is quite rigid, so that the four atoms of the peptide group –CO–NH– are coplanar and rigidly connected. This rigid configuration is connected on both sides to α-carbons and can rotate around the axes of these connections: these two rotation angles, although not able to take all values in [0, 2π), are degrees of freedom of the spatial configuration of the protein. Indeed the configuration of an n-amino acid protein is fully specified by 2n such angles.
The polypeptide chain has only a rotational freedom about the bonds formed by the α-carbons. These bonds have been termed the phi (φ) and psi (ψ) angles.

Two planar peptide groups on either side of an α-carbon (ball-and-stick model). Rotation is possible only about N–Cα (φ) and Cα–C′ (ψ); the arrows show the direction of positive rotation. Here both angles are about 180°.
The carbonyl carbon (the C of C=O) is often written as C′, and the hydrogens bonded to Cα and N, respectively, are written as Hα and HN. We refer to the N, Cα, C′, and O atoms as the peptide backbone. The peptide bond is ideally, although not in reality, planar and rigid, and rotation is allowed only by the φ (Cα–N) and ψ (Cα–C′) torsion angles. Given a sequence of n amino acids, we are interested in finding all torsion angles (φ1, ψ1, φ2, ψ2, …, φn, ψn) to determine the three-dimensional structure of the protein backbone.
The peptide bond has a torsion angle of its own, ω. Its partial double-bond character keeps ω near 180° (the trans form). The exception is the bond in front of a proline, where about 5% of peptide bonds are cis, with ω near 0°.
How fixed is "fixed"?
"Ideally, although not in reality" is worth checking. Ubiquitin's backbone is N, Cα, C repeated 76 times, so measure every bond length and angle along it:
import numpy as np
from primer import structure
chain = structure("1UBQ")[0]["A"]
residues = [r for r in chain if r.id[0] == " "]
print(len(residues), "residues,", sum(len(r) for r in residues), "protein atoms")
# The backbone as one long list of points: N, CA, C, N, CA, C, ...
bb = np.array([[r[a].coord for a in ("N", "CA", "C")] for r in residues]).reshape(-1, 3)
def angle(a, b, c):
u, v = a - b, c - b
return np.degrees(np.arccos(u @ v / np.linalg.norm(u) / np.linalg.norm(v)))
bonds = np.linalg.norm(np.diff(bb, axis=0), axis=1)
angles = np.array([angle(*bb[i:i + 3]) for i in range(len(bb) - 2)])
for k, name in enumerate(["N–Cα", "Cα–C", "C–N (peptide)"]):
print(f"bond {name:14} {bonds[k::3].mean():.3f} ± {bonds[k::3].std():.3f} Å")
for k, name in enumerate(["N–Cα–C (τ)", "Cα–C–N", "C–N–Cα"]):
print(f"angle {name:14} {angles[k::3].mean():6.1f} ± {angles[k::3].std():.1f}°")
76 residues, 602 protein atoms bond N–Cα 1.473 ± 0.017 Å bond Cα–C 1.522 ± 0.016 Å bond C–N (peptide) 1.319 ± 0.015 Å angle N–Cα–C (τ) 110.0 ± 3.6° angle Cα–C–N 116.8 ± 2.1° angle C–N–Cα 121.4 ± 2.4°
Bond lengths vary by about 0.02 Å and angles by a few degrees. The peptide C–N bond (1.32 Å) is shorter than the N–Cα single bond (1.47 Å): its partial double-bond character, visible in the coordinates. With lengths and angles fixed and ω pinned near 180°, ubiquitin's backbone comes down to 152 numbers, φ and ψ for 76 residues, plus up to four side-chain torsions per residue.
Computing a dihedral angle
A torsion, or dihedral, angle is defined by four atoms in order, p₁–p₂–p₃–p₄. The first three span one plane and the last three span another; the dihedral is the angle between the two planes, seen looking down the middle bond p₂→p₃. It is signed. By the IUPAC convention, it is positive when the front bond (p₂→p₁) must turn clockwise to cover the back bond (p₃→p₄). The range is (−180°, 180°].
The computation takes two cross products and an atan2. With bond vectors ,
, , the plane normals are and
. Then
atan2 rather than arccos is what gives the sign. The backbone torsions use these atoms:
| Angle | Atoms, in order | Rotation about |
|---|---|---|
| φ (phi) of residue i | C(i−1), N(i), Cα(i), C(i) | N–Cα |
| ψ (psi) of residue i | N(i), Cα(i), C(i), N(i+1) | Cα–C |
| ω (omega) after residue i | Cα(i), C(i), N(i+1), Cα(i+1) | C–N |
The first residue has no φ and the last has no ψ, because the atom before or after doesn't exist.
Drag the slider to rotate the last atom about the middle bond, or drag the 3D view to turn it. The Newman projection looks straight down the middle bond, and the table runs the formula above on live numbers. Mirroring the molecule flips the sign. Reading the four atoms backward leaves it unchanged, because the planes and the viewing direction both reverse.
The same computation on ubiquitin, checked against Biopython:
from Bio.PDB.vectors import calc_dihedral
def dihedral(p1, p2, p3, p4):
b1, b2, b3 = p2 - p1, p3 - p2, p4 - p3
n1, n2 = np.cross(b1, b2), np.cross(b2, b3)
y = np.cross(n1, n2) @ (b2 / np.linalg.norm(b2))
return np.degrees(np.arctan2(y, n1 @ n2))
prev, res, nxt = residues[6], residues[7], residues[8] # Thr 7, Leu 8, Thr 9
phi = dihedral(prev["C"].coord, res["N"].coord, res["CA"].coord, res["C"].coord)
psi = dihedral(res["N"].coord, res["CA"].coord, res["C"].coord, nxt["N"].coord)
omega = dihedral(res["CA"].coord, res["C"].coord, nxt["N"].coord, nxt["CA"].coord)
check = np.degrees(calc_dihedral(*[a.get_vector() for a in (prev["C"], res["N"], res["CA"], res["C"])]))
print(f"Leu 8: φ = {phi:.1f}°, ψ = {psi:.1f}°, ω = {omega:.1f}° (Biopython φ: {check:.1f}°)")
torsions = np.array([dihedral(*bb[i:i + 4]) for i in range(len(bb) - 3)])
psi_all, omega_all, phi_all = torsions[0::3], torsions[1::3], torsions[2::3]
print(f"ω over the chain: |ω| from {np.abs(omega_all).min():.1f}° to {np.abs(omega_all).max():.1f}°")
Leu 8: φ = -73.4°, ψ = -6.9°, ω = 179.9° (Biopython φ: -73.4°) ω over the chain: |ω| from 172.1° to 179.9°
Consecutive windows of four backbone atoms step through ψ, ω, φ in turn, which is how the last lines split the torsions. Ubiquitin has no cis peptide, so every ω is within 8° of 180°.
A backbone is a kinematic chain
There are two main models to represent a protein backbone: the all-atom Cartesian coordinates-based model and the dihedral angles-based model. In the Cartesian-based model, an energy minimization step is usually required to compute the correct bond lengths or angles of the protein structure. The dihedral angle-based model needs no such step. However, a dihedral angle change at one residue position will influence the positions of all subsequent residues.
Going from torsions back to coordinates is forward kinematics, the same problem as computing where a robot arm's hand ends up from its joint angles. Each new atom is placed from the three before it, given one bond length, one bond angle, and one torsion. This step is called NeRF (natural extension reference frame):
where points along the last bond, is the normal of the plane of the last three atoms, and completes the frame. The code rebuilds ubiquitin from its own internal coordinates and scores each model by RMSD (root-mean-square deviation), the standard measure of structural difference: superimpose the two structures as well as possible (the Kabsch algorithm, an SVD), then take the root of the mean squared distance between matching atoms. Under 1 Å is essentially the same structure; above 4–5 Å the backbones visibly differ.
def place(a, b, c, length, bond_angle, torsion):
"""The next atom d after a, b, c: |cd| = length, angle b-c-d = bond_angle, dihedral a-b-c-d = torsion."""
bc = (c - b) / np.linalg.norm(c - b)
n = np.cross(b - a, bc)
n /= np.linalg.norm(n)
m = np.cross(n, bc)
th, tau = np.radians(bond_angle), np.radians(torsion)
return c + length * (-np.cos(th) * bc + np.sin(th) * np.cos(tau) * m + np.sin(th) * np.sin(tau) * n)
def rebuild(lengths, bond_angles, tors):
pts = list(bb[:3]) # start from the real first residue
for i in range(3, len(bb)):
pts.append(place(pts[i - 3], pts[i - 2], pts[i - 1], lengths[i - 1], bond_angles[i - 2], tors[i - 3]))
return np.array(pts)
def rmsd(P, Q):
"""RMSD after the best rigid superposition (Kabsch)."""
P, Q = P - P.mean(0), Q - Q.mean(0)
U, _, Vt = np.linalg.svd(P.T @ Q)
R = Vt.T @ np.diag([1, 1, np.sign(np.linalg.det(Vt.T @ U.T))]) @ U.T
return np.sqrt(((P @ R.T - Q) ** 2).sum(1).mean())
ideal_len = np.resize([1.458, 1.525, 1.329], len(bonds)) # textbook N–Cα, Cα–C, C–N
ideal_ang = np.resize([111.2, 116.2, 121.7], len(angles)) # textbook N–Cα–C, Cα–C–N, C–N–Cα
flat_omega = torsions.copy()
flat_omega[1::3] = 180.0
nudged = torsions.copy()
nudged[3 * 30 + 2] += 10 # φ of residue 32, ten degrees
cases = [
("measured lengths, angles, and torsions", rebuild(bonds, angles, torsions)),
("one φ changed by 10°", rebuild(bonds, angles, nudged)),
("ideal lengths and angles, measured torsions", rebuild(ideal_len, ideal_ang, torsions)),
("ideal lengths and angles, every ω = 180°", rebuild(ideal_len, ideal_ang, flat_omega)),
]
for name, model in cases:
print(f"{name:45} RMSD {rmsd(model, bb):6.2f} Å")
measured lengths, angles, and torsions RMSD 0.00 Å one φ changed by 10° RMSD 1.02 Å ideal lengths and angles, measured torsions RMSD 4.07 Å ideal lengths and angles, every ω = 180° RMSD 4.72 Å
Every measured value reproduces the structure exactly. Changing one φ by 10° swings everything after residue 32 as a rigid body: RMSD 1 Å, with some downstream atoms moving more than 3 Å. Textbook bond geometry, off by a couple of degrees per angle, puts the model 4 Å away, and forcing every ω to 180° makes it slightly worse. Small errors at each joint add up over 76 residues, so torsion-space methods must correct for the drift. Lesson 3.3 builds regular helices with the same placement step.
Check yourself
A program reports φ = +60° for a residue, and you recompute it with the same four atoms listed in reverse order (C(i), Cα(i), N(i), C(i−1)). What do you get, and what would change the sign?
Reasoning
You get +60° again. Reversing the order reverses the viewing direction and swaps which bond is in front, and the two changes cancel. Only a reflection changes the sign, as when the molecule is mirrored or one atom is moved through the plane of the other three. Swapping two atoms out of order (C(i−1), Cα, N, C) gives an unrelated angle, not the negative.
A Cartesian-coordinate optimizer and a torsion-angle optimizer each move one residue's backbone by a small amount. Which change disturbs residues 50 positions away, and which one breaks bond lengths?
Reasoning
The torsion change moves everything downstream, because each later atom is placed relative to the ones before it: residue 50 positions away moves as a rigid body and, in a folded protein, may run into other atoms. It keeps every bond length and angle exact. The Cartesian move is local, so faraway atoms stay put, but it can stretch bonds and bend angles, which is why Cartesian methods follow up with energy minimization.
How many free backbone torsions does a 300-residue protein have if ω is held at 180°? If a design program tries 3 values for each, how many backbones is that? Compare with the number of atoms in the observable universe, about .
Reasoning
2 × 300 = 600 torsions (598 if you drop the missing φ of the first residue and ψ of the last). backbones, 10²⁰⁶ times the atoms in the universe. Enumeration is hopeless, so prediction and design rely on knowing which (φ, ψ) pairs are allowed (lesson 3.2), on energy functions, and on learned models.