Mathew Smith wrote: > I would like to measure the rmsd between the secondary structure elements of my > models and the templates. > I have been trying to do this using the selection.superpose method, as shown in > the example file examples/commands/pick_atoms.py, to select a range of > residues. But it keeps giving the following error: ... > KeyError: 'No such residue: 4' > > I have only been programming for a few months and can't see why it is giving > this KeyError?
Like it says, there's no residue called "4" in your model. You should check your PDB file to make sure it's there! A common error is to forget the chain ID - if your residue is in chain A, you need to specify this, e.g.
s = selection(mdl.residue_range('4:A', '10:A'))
If in doubt, you could add a little loop to print all the residues with something like:
for r in mdl.residues: print r
Ben Webb, Modeller Caretaker