Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 49 ยท Structural Bioinformatics

Superposition and RMSD: Comparing Protein Structures

Learn how to superpose two protein structures with the Kabsch algorithm, compute RMSD, avoid its pitfalls, and use TM-score, GDT and lDDT for better comparisons.

How different are two protein structures? You might be comparing the same enzyme with and without a drug bound, a predicted model with an experimental structure, or two distant relatives in different species. Looking at them side by side is a start, but you need a number. The standard answer is the root-mean-square deviation (RMSD): a kind of average distance between corresponding atoms.

The catch is that RMSD only makes sense after the two structures have been moved to their best overlap, since each file has its own arbitrary coordinate frame. The act of finding that best overlap is called superposition, and the classic way to do it is the Kabsch algorithm, which fits in a dozen lines of NumPy. In this lesson you will write it, test it, and learn why a single RMSD number can mislead.

Two panels with seven matched points each: before superposition, a pink chain rotated away from an indigo chain; after, the chains overlap with short dashed distances and an RMSD label. Three steps below.
Caption: centre both point sets, find the best rotation with an SVD, then average the squared distances that remain.

What you will learn

  • What RMSD measures and how to compute it by hand.
  • Why superposition is needed and how the Kabsch algorithm finds the optimal rotation.
  • How to avoid the mirror-image trap.
  • Why RMSD can mislead, and which measures (TM-score, GDT, lDDT) complement it.

Key terms

RMSD: sqrt( (1/N) * sum of d_i^2 ), where d_i is the distance between the i-th matched pair of atoms.

Superposition: moving (translating and rotating) one structure to minimize its RMSD to another.

Rotation matrix: a 3 by 3 matrix with determinant +1 that rotates points without distorting them.

Equivalence (correspondence): the list of which atom in one structure matches which atom in the other.

TM-score: a length-independent similarity score between 0 and 1.

What RMSD measures

Suppose you compare two chains using their C-alpha atoms, so each has N atoms and atom i in the first chain corresponds to atom i in the second. After superposition, atom i is separated from its partner by a distance d_i. The RMSD is

RMSD = sqrt( (d_1^2 + d_2^2 + ... + d_N^2) / N )

A small example: three atoms are 1 ร…, 2 ร… and 2 ร… from their partners. The mean of the squares is (1 + 4 + 4) / 3 = 3, so the RMSD is sqrt(3), about 1.73 ร…. Note that this is not the plain average distance (1.67 ร…). Squaring makes large deviations count more, so one atom that is far away raises the RMSD noticeably.

For the same protein in two states, an RMSD of 0.5 ร… means the structures are nearly identical within experimental error. Differences of 1 to 3 ร… are typical for flexible movements, and homologous proteins with similar folds commonly differ by about 1 to 3 ร… over their conserved core. There is no universal threshold, because the meaning depends on the number of atoms and on which ones you included.

The correspondence problem

RMSD needs to know which atom pairs with which. For two structures of the same protein with the same sequence, that is easy: residue 25 pairs with residue 25 (watch for missing residues and different numbering). For homologous proteins with different sequences, you first need a structural alignment that decides which residues are equivalent. Programs such as TM-align, DALI, CE and FATCAT search over alignments and superpositions together. The result depends on the alignment you choose, a point worth keeping in mind when reading a quoted RMSD.

Most comparisons use only the C-alpha atoms, one per residue, which gives a robust summary of the backbone. For comparing ligand poses or active sites, you use all heavy atoms of the relevant part.

Why superposition is needed

Each structure file places its molecule in an arbitrary position and orientation in space. If you compute RMSD directly from raw coordinates, you mostly measure how far apart the molecules happen to be. The fix is to find the rigid-body transformation (a translation plus a rotation, no stretching) that brings one set of points as close as possible to the other, then measure what remains.

Translation is easy: the optimal translation superimposes the centroids (the mean positions). Rotation is the hard part, because the rotation that minimizes the sum of squared distances is not obvious. In 1976 Wolfgang Kabsch gave an exact solution.

The Kabsch algorithm

Given two N by 3 coordinate arrays P (to be moved) and Q (target):

  1. Subtract each set's centroid, giving centred arrays A and B.
  2. Compute the 3 by 3 covariance matrix H = A^T B.
  3. Compute its singular value decomposition H = U S V^T.
  4. Compute d = sign(det(V U^T)).
  5. The optimal rotation is R = V diag(1, 1, d) U^T.
  6. Apply R to the centred P and add back the centroid of Q.

Step 4 is subtle and important. Without it, the algorithm can return an improper rotation, a reflection, which has determinant -1. A reflection can give a lower RMSD but turns your protein into its mirror image, which is chemically a different molecule (amino acids are chiral). The sign correction guarantees a proper rotation. The whole method runs in time proportional to N, so it is fast enough for molecular dynamics trajectories with millions of frames. Other formulations, such as Horn's quaternion method and Theobald's QCP, give the same minimum.

When a single RMSD misleads

  • Outliers and mobile loops. A single floppy loop that moved 10 ร… can dominate the RMSD of an otherwise perfectly matching protein.
  • Hinge motion. Many proteins are two rigid domains joined by a flexible linker. Superposing the whole molecule gives a large RMSD that describes neither domain well. Superpose domain by domain instead, and report the hinge angle.
  • Size dependence. For random comparisons, RMSD grows with chain length, so 3 ร… over 50 residues means something different from 3 ร… over 500.
  • No location information. One number does not say where the differences are. Plot the per-residue distance after superposition.

Complementary measures address these limits:

Measure What it is Typical use
TM-score length-normalized score from 0 to 1 that weights close pairs more values above about 0.5 usually indicate the same fold, below about 0.17 are like random pairs
GDT_TS average percentage of C-alpha atoms within 1, 2, 4 and 8 ร… after best superposition the main metric in the CASP structure prediction experiments
lDDT compares local distance patterns, no superposition needed robust to domain movement; underlies the pLDDT confidence of AlphaFold

A newer tool, Foldseek, encodes structures in a small alphabet describing local geometry, which lets it search enormous databases such as the AlphaFold models for similar folds in seconds.

Common misconceptions

"Lower RMSD always means more similar." Not when the atom sets differ, when a reflection slipped in, or when a hinge makes the global number meaningless. Always say which atoms and alignment were used.

"RMSD of 2 ร… is bad." It depends on the question. For two crystal structures of one protein it indicates a real conformational difference; for distant homologs it indicates a close match.

"You can compare RMSDs of different-length proteins directly." Longer chains generally have larger RMSDs for the same level of similarity; use TM-score for length-independent comparison.

Try it

The first example implements Kabsch, hides a known rotation in a noisy copy and recovers it. The second shows what the sign correction prevents. The third plots per-residue deviations for a hinge motion, comparing whole-molecule and per-domain superposition.

Python The Kabsch algorithm

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python The mirror-image trap

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Hinge motion: whole-molecule versus per-domain fit

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Three matched atom pairs are 1 ร…, 1 ร… and 4 ร… apart after superposition. What is the RMSD?

    RMSD = sqrt((1 + 1 + 16) / 3) = sqrt(6), about 2.45 ร…. The plain mean distance would be 2 ร….
  2. 2. What does the sign correction d = sign(det(V U^T)) in the Kabsch algorithm prevent?

    Without it the SVD can return an improper rotation with determinant -1.
  3. 3. Why does superposing a two-domain protein as a single rigid body often give a large RMSD?

    Hinge or domain motions mean no single rigid transformation matches the whole molecule.
  4. 4. Which measure needs no superposition at all?

    lDDT compares local distance patterns between atoms, so it does not require a rigid-body fit.
  5. 5. What is the first step of the Kabsch algorithm?

    Translation is solved first by centring both sets; then the rotation is found from the covariance matrix.

Summary

  • RMSD is the square root of the mean squared distance between matched atoms; it needs a correspondence and a superposition.
  • Kabsch: centre both sets, form H = A^T B, take the SVD, correct the sign of the determinant, and build R = V diag(1, 1, d) U^T.
  • The determinant correction prevents mirror-image fits.
  • RMSD is sensitive to outliers, hinges and size; plot per-residue deviations and consider TM-score, GDT_TS or lDDT.
  • Always report which atoms, which alignment and which superposition were used.

Next: Structure Prediction and Docking