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:
File "superimpose.py", line 13, in ? s = selection(mdl.residue_range('4','10')) File "/usr/lib/modeller9v1/modlib/modeller/coordinates.py", line 64, in residue_range start = self.residues[start]._num File "/usr/lib/modeller9v1/modlib/modeller/coordinates.py", line 165, in __getitem__ (self.offset, self.length, self.suffix)) File "/usr/lib/modeller9v1/modlib/modeller/util/modutil.py", line 76, in handle_seq_indx int_indx = lookup_func(*args) File "/usr/lib/modeller9v1/modlib/modeller/coordinates.py", line 50, in _indxres raise KeyError, ("No such residue: %s" % indx) KeyError: 'No such residue: 4'
I have only been programming for a few months and can't see why it is giving this KeyError? I am I using the correct script and commands for the job?
Here is a copy of my script:
from modeller import *
log.verbose() env = environ() env.io.atom_files_directory = '/scratch/mobsfms2/protest/rmsd/' env.libs.topology.read(file='/usr/lib/modeller9v1/modlib/top_heav.lib') env.libs.parameters.read(file='/usr/lib/modeller9v1/modlib/par.lib')
mdl = model(env, file='renumb_1BV4_a') mdl2 = model(env, file='mbpc_21muscle') aln = alignment(env, file='models.ali', align_codes=('renumb_1BV4_a','mbpc_21muscle'))
s = selection(mdl.residue_range('4','10'))
r = s.superpose(mdl2, aln)
# We can now use the calculated RMS, DRMS, etc. from the returned 'r' object: rms = r.rms drms = r.drms print "%d equivalent positions" % r.num_equiv_pos
mdl2.write(file='mbpc_21muscle.fit')
Mat
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
participants (2)
-
Mathew Smith
-
Modeller Caretaker