Every experimentally determined or predicted protein structure has to answer one question first: are its backbone angles physically possible? The Ramachandran plot answers it in a single glance, and it is the reason a crystallographer's or an AlphaFold model's first quality check looks the way it does. This project computes it from a real PDB structure.
demo.py downloads the real 1CRN (crambin) structure live from RCSB and falls back to the bundled real copy. Every point is a genuine backbone dihedral computed from the atomic coordinates.
A protein backbone has two rotatable angles per residue — phi and psi — and steric clashes forbid most of their combinations. The allowed combinations cluster into a few islands: right-handed α-helix, β-sheet, and a small left-handed region (mostly glycines). Plotting every residue's phi/psi against those islands is how you validate a structure: points crowding the allowed regions mean sensible geometry, while outliers flag modelling errors, strained residues, or genuinely unusual conformations worth a second look. In the demo, crambin's residues fall cleanly into the helix and sheet regions — as they should for a well-resolved 1.5 Å structure.
- Parse the backbone. Read the N, CA, and C atoms of every residue by fixed PDB column positions.
- Compute dihedrals. phi from (C₋₁, N, CA, C) and psi from (N, CA, C, N₊₁), using a numpy dihedral function — no external structural library.
- Plot against the allowed regions. Shade the favoured islands, colour glycine and proline separately (they follow different rules), and count how many residues land in each region.
This is a validation view, not a full structure-quality suite — MolProbity and the wwPDB validation pipeline check clashes, rotamers, and bond geometry that a Ramachandran plot alone cannot see. Glycine (very flexible) and proline (very restricted) need their own reference regions, which is why the demo marks them separately; do not judge them against the general contours.
A beautiful cartoon render can hide a structure with impossible geometry. The Ramachandran plot does not care how pretty the ribbon is — a residue in a forbidden region is a red flag no rendering can disguise. If a model's points scatter outside the allowed islands, distrust it, whatever it looks like in a viewer.
pip install -r requirements.txt
python demo.py # downloads the real structure (or uses the bundled copy offline)rama_utils.py provides download_pdb, parse_backbone, dihedral, and phi_psi for reuse on any PDB ID.
Method: Ramachandran, G.N. et al., J. Mol. Biol. 7:95 (1963). Structure 1CRN via the RCSB Protein Data Bank (https://www.rcsb.org/structure/1CRN).
Demonstrated on a real PDB structure. The demo downloads it live and ships a bundled copy, so it is fully reproducible with or without network access.
