How to Fix Missing Residues and Loops in a PDB Structure Before Docking or MD (ChimeraX, SWISS-MODEL and MODELLER)

To fix missing residues in a PDB structure, read REMARK 465 to list the residues that were never resolved, compare SEQRES against the ATOM records to place each gap, then rebuild only the gaps that matter. ChimeraX Model Loops, SWISS-MODEL user-template mode and MODELLER LoopModel all do the rebuilding. Validate the new loop before docking or MD.
A student downloads a structure, opens it in PyMOL, sees a protein, and assumes the file is complete. Two hours later gmx pdb2gmx throws an error nobody warned them about, or a docking box ends up centred on a pocket with one wall missing. The cause is the same either way: the crystal structure has holes in it, and the viewer drew a smooth ribbon straight over them. This guide covers how to find those holes, which ones are worth filling, and three ways to fill them. Written by the StemSkills Lab team, from 10+ years in sequence and structural bioinformatics, drug discovery and design, and multiscale molecular modeling.
What are missing residues, and why does your run break?
An X-ray structure is a model fitted into electron density. Where a segment of the chain is flexible, the density smears out and the crystallographer cannot place atoms there with confidence, so they leave them out. The residue is still in the protein. It is simply absent from the coordinate file.
This is not a rare edge case. The SEQATOMS paper surveyed 109,205 PDB protein chains and reported that “as many as 64% of these proteins had at least one missing, or lower-case masked, residue and 26% had at least ten missing residues” (Brandt, Heringa and Leunissen, Nucleic Acids Research 36:W255-W259, 2008). Most gaps sit at the termini or in surface loops, which is exactly where a flexible segment would be.
Three things then go wrong downstream:
- MD topology building fails or lies. GROMACS
pdb2gmxwalks the chain and expects every atom the force field’s.rtpentry defines. A gap produces either a hard error or, worse, a topology that silently bonds two residues that are 14 Å apart. The GROMACS run-time errors documentation is blunt about the tempting shortcut: “the use of the option-missingis almost always inappropriate”. Reach for it and “the topology produced is likely physically unrealistic”. More failure modes are collected in our guide to common GROMACS errors. - The binding site is the wrong shape. If a missing loop forms one face of the pocket, your docking grid encloses an opening that does not exist in the real protein. Ligands drift into a cavity that solvent would occupy.
- Your methods section is unreproducible. “The structure was downloaded from the RCSB PDB” tells a reviewer nothing about the eleven residues you quietly rebuilt.
How do you find the missing residues in your structure?
Four checks, in increasing order of effort. Do the first one always.
1. Read REMARK 465 directly
The wwPDB format specification defines REMARK 465 as the record listing residues present in SEQRES but completely absent from the coordinates. The header text in the file reads “MISSING RESIDUES / THE FOLLOWING RESIDUES WERE NOT LOCATED IN THE EXPERIMENT”, followed by columns for model number, residue name, chain identifier and sequence number.
grep "REMARK 465" 3poz.pdb
Its sibling, REMARK 470, lists standard residues whose side chains are incomplete. That is a different and usually easier problem: most preparation tools rebuild a truncated lysine side chain without being asked. REMARK 465 is the one that breaks chains.
2. Compare SEQRES against the ATOM records
SEQRES holds the sequence of the construct that was crystallised. The ATOM records hold what was actually seen. Any residue in the first and not the second is missing. This is the check that catches structures where REMARK 465 is absent or incomplete, and it is what tools such as SEQATOMS automate.
3. Look at the RCSB entry page
The structure summary page for each entry renders the sequence with unobserved stretches marked, so you can see at a glance whether a gap sits in a loop or eats half a domain. Our walkthrough on downloading a protein structure from the RCSB PDB covers where that panel lives.
4. Open it in ChimeraX and look at the chain
Open the structure, then open Tools > Sequence > Sequence Viewer. Residues with no coordinates appear without the light box that marks resolved positions, and clicking either side of a gap selects the flanking residues in 3D. This matters because you are about to make a judgement call about location, and a sequence number alone will not tell you whether residue 723 sits next to your ligand. If ChimeraX is new to you, start with our ChimeraX tutorial for beginners.
Which gaps actually need filling?
Not all of them. Rebuilding a loop invents coordinates, and invented coordinates carry error. The honest default is to fill a gap only when leaving it would change your result.
| Gap | For docking | For MD |
|---|---|---|
| Terminal residues (before the first or after the last resolved residue) | Leave out. Cap the truncated terminus. | Leave out. Cap with ACE/NME or use charged termini deliberately. |
| Internal gap, 1-3 residues, far from the site | Optional, low risk either way | Fill. A chain break is a topology problem regardless of location. |
| Internal gap, 1-3 residues, lining the pocket | Fill | Fill |
| Internal gap, 4-12 residues | Fill, then validate carefully | Fill, then validate carefully |
| Internal gap longer than ~15 residues | Do not loop-model it. Use a full homology model or an AlphaFold model instead. | |
The asymmetry between the two columns is the part students miss. Docking treats the receptor as rigid and only samples the pocket, so a distant gap is often irrelevant. MD needs a continuous, physically sane topology for the whole chain, which is why the protein preparation workflow for MD is stricter than the one for preparing a protein and ligand for docking.
The last row deserves emphasis. Loop modelling optimises a segment inside a fixed environment, and past roughly 15 residues the conformational search space outgrows what that optimisation can cover. If a whole helix or domain is unresolved, build the model properly instead: see predicting a protein structure with AlphaFold, the step that precedes preparation in our structural bioinformatics learning path.
How do you rebuild a loop in ChimeraX?
This is the fastest route and the one to learn first. ChimeraX ships a Model Loops tool that drives MODELLER for you, either through a web service or a local install (Meng et al., Protein Science 32:e4792, 2023).
- Open the structure and its sequence, so the tool knows what should be there.
- Go to Tools > Structure Prediction > Model Loops.
- Set the region to build. The default is all missing structure; switch it to internal missing structure when you want the gaps filled but the ragged termini left alone. That single choice is the most useful setting in the dialog.
- Set adjacent flexible residues. The default is 1 per segment end, meaning one resolved residue either side is allowed to move so the new segment can join without strain. Raise it to 2 for longer gaps.
- Set number of models. The default is 5. Generating several and picking the best by score beats trusting a single attempt.
- Choose the protocol. DOPE or DOPE-HR scores conformations more carefully than the standard protocol and is worth the extra time for a pocket-adjacent loop.
The equivalent command exists too. The ChimeraX modeller command documentation gives this literal example:
modeller loops 1/A:1:all adjacent 0 num 3
Here all is shorthand for all-missing and internal for internal-missing, while adjacent and num map to the two dialog settings above. ChimeraX opens the resulting models in a list with their scores so you can step through them.
One prerequisite catches everyone: MODELLER needs a licence key. Academic registration is free at the Sali Lab site, and ChimeraX stores the key in its preferences after the first run.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
How do you rebuild a gap in SWISS-MODEL using your structure as its own template?
If you cannot install anything, or you want a second independent model to compare against, SWISS-MODEL will do the job in a browser. The trick is that the template does not have to be a different protein. It can be your own incomplete structure.
- Go to SWISS-MODEL and press User Template.
- Paste the complete target sequence, gaps included. Take it from the UniProt entry or from the SEQRES records, not from the ATOM records, since the ATOM sequence is the one with holes in it.
- Click Add Template File and upload your structure. The SWISS-MODEL help pages state that only PDB format is accepted here and that mmCIF is not supported, so convert first if you downloaded a
.cif. - Strip modified residues and stray HETATM records before uploading. The documentation warns explicitly to make sure there are no chemically modified amino acids, and this is the most common reason a file is rejected.
- Build. The server aligns your full sequence to the uploaded coordinates and models the unaligned stretches, returning a complete chain.
The output carries two quality numbers you should record. GMQE runs 0 to 1, with higher expected to be better. QMEANDisCo gives both a global score and a per-residue curve, and the help pages set the threshold plainly: residues scoring below 0.6 are expected to be of low quality. Look at the per-residue curve across your rebuilt segment, not just the global number, since a good global score can hide one bad loop. The method behind those scores is described in Waterhouse et al., Nucleic Acids Research 46:W296-W303, 2018. Our SWISS-MODEL homology modelling tutorial covers the rest of the interface.
How do you rebuild missing residues with MODELLER directly?
MODELLER is the engine underneath both of the routes above (Šali and Blundell, Journal of Molecular Biology 234:779-815, 1993). Driving it yourself gives you control over which atoms are allowed to move, which matters when you must guarantee that the resolved part of the structure is untouched.
The official MODELLER wiki page on missing residues gives the procedure. First extract the sequence as MODELLER sees it:
from modeller import * code = '1qg8' e = Environ() m = Model(e, file=code) aln = Alignment(e) aln.append_model(m, align_codes=code) aln.write(file=code+'.seq')
Then build an alignment file with two entries: the structure (dashes where residues are missing) as structureX, and the full sequence with no gaps as sequence. Finally run a LoopModel job:
from modeller import *
from modeller.automodel import *
env = Environ()
env.io.atom_files_directory = ['.', '../atom_files']
a = LoopModel(env, alnfile = 'alignment.ali',
knowns = '1qg8', sequence = '1qg8_fill')
a.starting_model = 1
a.ending_model = 1
a.loop.starting_model = 1
a.loop.ending_model = 2
a.loop.md_level = refine.fast
a.make()
Two lines deserve attention. a.loop.ending_model sets how many loop conformations are generated per starting model, so raise it from 2 to 10 or 20 when the gap borders your binding site, then rank by DOPE score. a.loop.md_level = refine.fast selects the refinement protocol; refine.slow costs more time and generally produces better geometry. The optimisation is described in Fiser, Do and Šali, Protein Science 9:1753-1773, 2000, which is the paper to cite in a methods section.
To hold the resolved region completely fixed, override select_atoms() so only the missing residue ranges are selected for optimisation. Without that override the whole model relaxes and your rebuilt structure no longer superposes exactly onto the deposited one. If you want the same result without installing anything, the ModLoop web server at the Sali Lab runs this loop protocol on a submitted structure and emails the result back.
Which tool should you choose?
| Criterion | ChimeraX Model Loops | SWISS-MODEL (user template) | MODELLER script |
|---|---|---|---|
| Install needed | ChimeraX + MODELLER licence key | None, browser only | MODELLER + Python |
| Cost | Free for academic use | Free | Free for academic use |
| Learning curve | Low, GUI dialog | Low, web form | High, alignment file by hand |
| Control over which atoms move | Moderate (adjacent flexible residues) | Low | Full (select_atoms()) |
| Multiple conformations ranked | Yes, number of models | No, one model per job | Yes, loop model range |
| Built-in quality score | Per-model score in the results list | GMQE and QMEANDisCo | DOPE score |
| Fits best when | You are already in ChimeraX preparing the structure | You are on a lab machine you cannot install on | The gap is near the pocket and reproducibility matters |
For most BSc and MSc projects, ChimeraX is the right default. Move to a MODELLER script when a reviewer will ask exactly which residues you rebuilt and how.
How do you validate the rebuilt loop before docking or MD?
A rebuilt loop is a prediction. Treat it like one.
- Look at it. Superpose the rebuilt model onto the original and check that the new segment does not thread through the binding site, clash with a ligand, or cross another chain. This catches more errors than any score.
- Check the geometry. Run a Ramachandran analysis and a clash check on the rebuilt residues specifically, not just on the whole structure, where a handful of bad residues disappear into the average. Our guide on how to validate a protein structure covers what the MolProbity numbers mean.
- Check chain continuity. Measure the distance between consecutive C and N atoms across each former gap. A peptide bond is about 1.33 Å. Anything above ~2 Å means the loop did not actually close.
- Compare two independent rebuilds. If ChimeraX and SWISS-MODEL place the loop in roughly the same position, you have some confidence. If they disagree completely, the segment is genuinely disordered and you should say so rather than pretend otherwise.
- Re-run the step that failed. For MD, the real test is that
pdb2gmxnow completes without a chain-break warning. Our GROMACS pdb2gmx tutorial walks through reading its output properly.
Then write it down. A defensible methods sentence names the PDB entry, the exact residue ranges, the tool and the version you ran, the protocol, and what was held fixed: residues 1002-1005 and 1019-1023 of chain A were absent from the deposited coordinates and were rebuilt with MODELLER using the DOPE-HR protocol, with all resolved atoms restrained. Structure preparation sits early in the staged path in our computational biology skills roadmap, and getting it right is what makes every later step trustworthy.
What goes wrong, and how do you fix it?
- Model Loops is greyed out or reports no sequence. The tool compares coordinates against a sequence, so the structure needs an associated sequence in the Sequence Viewer. Open Tools > Sequence > Sequence Viewer for the relevant chain first.
- MODELLER refuses to start without a licence key. Register for the free academic key at the Sali Lab site and enter it in the ChimeraX dialog or set it in your MODELLER install. There is no way around this step.
- SWISS-MODEL rejects your template file. Delete HETATM records, waters, and any chemically modified residues, and convert mmCIF to PDB. Modified residues are the usual culprit.
- MODELLER reports that the alignment sequence does not match the structure. The
knownsandsequencenames in the script must match the>P1;codes in the alignment file exactly, and thestructureXline’s residue range must match the first and last resolved residues in the PDB. - The rebuilt loop passes through the binding site. Generate more conformations and rank them rather than accepting the first. Raise the number of models in ChimeraX or
a.loop.ending_modelin MODELLER, and switch to DOPE-HR orrefine.slow. - pdb2gmx still errors with “atom not found in rtp entry”. That message is about atom naming, not gaps. Check the naming convention your force field expects, and use
-ignhso GROMACS adds hydrogens itself. - You are tempted by
pdb2gmx -missing. Do not use it on a protein. The GROMACS documentation restricts it to specialised topologies for amino-acid-like molecules and warns that the result is likely physically unrealistic.
Frequently asked questions
Can I just delete the residues around the gap instead of rebuilding?
Only if the gap is at a terminus. Deleting internal residues shortens the chain and leaves the same discontinuity, so pdb2gmx still sees a break. Terminal truncation is standard practice and simply needs the new terminus capped or charged deliberately.
Can I use AlphaFold to fill the missing loop?
You can superpose an AlphaFold model on the crystal structure and graft the corresponding segment across, and for long gaps this often beats loop modelling. Check the pLDDT of the grafted segment first, because AlphaFold usually gives low confidence exactly where the crystallographer saw no density. Our comparison of AlphaFold, homology modelling and experimental structures covers when to choose which.
Do missing side-chain atoms matter as much as missing whole residues?
Less, but they still matter when the residue lines the pocket. Missing side chains are listed in REMARK 470 and are rebuilt automatically by most preparation tools. A truncated arginine in your binding site is worth checking against our guide on finding a protein binding site for docking.
Should I minimise the structure after rebuilding the loop?
A short restrained minimisation with the resolved atoms held in place cleans up residual strain at the junctions without moving the experimental coordinates. For MD this happens anyway during the standard energy-minimisation step, so it is only worth doing separately before docking.
How do I report this in my thesis?
Give the PDB ID, the exact residue ranges that were absent, the tool and version used, the protocol and number of models generated, the selection criterion, and the validation you ran on the rebuilt segment. Anyone who repeats those steps should land on the same structure.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
