# Find the template matching each residue and assign atom types.
forchainintopology.chains():
forresinchain.residues():
# Attempt to match one of the existing templates.
[template,matches]=getResidueTemplateMatches(res)
ifmatchesisNone:
# No existing templates match. Try any registered residue template generators.
forgeneratorinself._residueTemplateGenerators:
ifgenerator(forcefield,res):
# This generator has registered a new residue template that should match.
[template,matches]=getResidueTemplateMatches(res)
ifmatchesisNone:
# Something went wrong because the generated template does not match the residue signature.
raiseException('The residue handler %s indicated it had correctly parameterized residue %s, but the generated template did not match the residue signature.'%(generator.__class__.__name__,str(res)))
else:
# We successfully generated a residue template. Break out of the for loop.
break
# Raise an exception if we have found no templates that match.
ifmatchesisNone:
ifmatchesisNone:
raiseValueError('No template found for residue %d (%s). %s'%(res.index+1,res.name,_findMatchErrors(self,res)))
raiseValueError('No template found for residue %d (%s). %s'%(res.index+1,res.name,_findMatchErrors(self,res)))
# Store parameters for the matched residue template.