Hi,
I had sucessfull modelled a protein without restrains.
However, when I put alpha helix restrains in the script below I face this problem:
File "model-restriction-single.py", line 21 rsr.add(secondary_structure.alpha(self.residue_range('47:', '57:'))) ^ IndentationError: unindent does not match any outer indentation level
I saw the script too many times and I am not able to see where the problem is.
Could anyone help-me?
from modeller import *
from modeller.automodel import *
log.verbose()
env = environ()
env.io.hetatm = True
# directories for input atom files
env.io.atom_files_directory = ['.', '../atom_files']
class MyModel(automodel):
def special_restraints(self, aln):
rsr = self.restraints
at = self.atoms
# Add some restraints from a file:
# Residues 47 through 57 should be an alpha helix:
rsr.add(secondary_structure.alpha(self.residue_range('47:', '57:')))
# Residues 130 through 140 should be an alpha helix:
rsr.add(secondary_structure.alpha(self.residue_range('130:', '140:')))
# Residues 182 through 184 should be an alpha helix:
rsr.add(secondary_structure.alpha(self.residue_range('182:', '184:')))
# Residues 191 through 195 should be an alpha helix:
rsr.add(secondary_structure.alpha(self.residue_range('191:', '195:')))
a = MyModel(env, alnfile='MODEL-TemplateA.ali',
knowns='TemplateA', sequence='MODEL',
assess_methods=(assess.DOPE, assess.GA341))
a.starting_model = 1
a.ending_model = 5 0 a.make()
# Get a list of all successfully built models from a.outputs
ok_models = filter(lambda x: x['failure'] is None, a.outputs)
# Rank the models by DOPE score
key = 'DOPE score'
ok_models.sort(lambda a,b: cmp(a[key], b[key]))
# Get top model
m = ok_models[0]
print "Top model 1: %s (DOPE score %.3f)" % (m['name'], m[key])
m = ok_models[1]
print "Top model 2: %s (DOPE score %.3f)" % (m['name'], m[key])
m = ok_models[2]
print "Top model 3: %s (DOPE score %.3f)" % (m['name'], m[key])
m = ok_models[3]
print "Top model 4: %s (DOPE score %.3f)" % (m['name'], m[key])
m = ok_models[4]
print "Top model 5: %s (DOPE score %.3f)" % (m['name'], m[key])
Hey Flávio,
It's a Python syntax problem. You have a leading space before those lines (all starting with rsr.add). Remember that in Python, white-space *is* important. Removing that space will make it work.
Cheers,
João [...] Rodrigues http://nmr.chem.uu.nl/~joao
On Sat, Jun 18, 2011 at 8:01 PM, flavio seixas oivalf_nix@yahoo.com wrote:
> Hi, > > I had sucessfull modelled a protein without restrains. > > However, when I put alpha helix restrains in the script below I face this > problem: > > > File "model-restriction-single.py", line 21 > rsr.add(secondary_structure.alpha(self.residue_range('47:', '57:'))) > ^ > IndentationError: unindent does not match any outer indentation level > > > I saw the script too many times and I am not able to see where the problem > is. > > Could anyone help-me? > > > from modeller import * > > from modeller.automodel import * > > > > log.verbose() > > env = environ() > > > > env.io.hetatm = True > > > > # directories for input atom files > > env.io.atom_files_directory = ['.', '../atom_files'] > > > > > > class MyModel(automodel): > > def special_restraints(self, aln): > > rsr = self.restraints > > at = self.atoms > > > > # Add some restraints from a file: > > > > # Residues 47 through 57 should be an alpha helix: > > rsr.add(secondary_structure.alpha(self.residue_range('47:', '57:'))) > > > > # Residues 130 through 140 should be an alpha helix: > > rsr.add(secondary_structure.alpha(self.residue_range('130:', '140:'))) > > > > # Residues 182 through 184 should be an alpha helix: > > rsr.add(secondary_structure.alpha(self.residue_range('182:', '184:'))) > > > > # Residues 191 through 195 should be an alpha helix: > > rsr.add(secondary_structure.alpha(self.residue_range('191:', '195:'))) > > > > > > > > a = MyModel(env, alnfile='MODEL-TemplateA.ali', > > knowns='TemplateA', sequence='MODEL', > > assess_methods=(assess.DOPE, assess.GA341)) > > a.starting_model = 1 > > a.ending_model = 5 > 0 > a.make() > > > > > > # Get a list of all successfully built models from a.outputs > > ok_models = filter(lambda x: x['failure'] is None, a.outputs) > > > > > > # Rank the models by DOPE score > > key = 'DOPE score' > > ok_models.sort(lambda a,b: cmp(a[key], b[key])) > > > > > > > > # Get top model > > m = ok_models[0] > > > > print "Top model 1: %s (DOPE score %.3f)" % (m['name'], m[key]) > > m = ok_models[1] > > > > print "Top model 2: %s (DOPE score %.3f)" % (m['name'], m[key]) > > m = ok_models[2] > > > > print "Top model 3: %s (DOPE score %.3f)" % (m['name'], m[key]) > > m = ok_models[3] > > > > print "Top model 4: %s (DOPE score %.3f)" % (m['name'], m[key]) > > m = ok_models[4] > > > > print "Top model 5: %s (DOPE score %.3f)" % (m['name'], m[key]) > > > > > _______________________________________________ > modeller_usage mailing list > modeller_usage@salilab.org > https://salilab.org/mailman/listinfo/modeller_usage >
On 6/18/11 11:01 AM, flavio seixas wrote: > However, when I put alpha helix restrains in the script below I face this problem: > > File "model-restriction-single.py", line 21 > rsr.add(secondary_structure.alpha(self.residue_range('47:', '57:'))) > ^ > IndentationError: unindent does not match any outer indentation level
The start of the line "rsr.add(..." must line up with the start of the previous code line "at = self.atoms" (and the same for your other secondary structure restraints). Add some spaces to fix this.
Ben Webb, Modeller Caretaker
participants (3)
-
flavio seixas
-
João Rodrigues
-
Modeller Caretaker