## Automatic loop refinement after model building

To automatically refine loop regions after building standard `automodel` models, simply use the `loopmodel` class rather than `automodel`; see the example below.

In many cases, you can obtain better quality loops (at the expense of more computer time) by using the newer DOPE-based loop modeling protocol. In this case, just use the `dope_loopmodel` or `dopehr_loopmodel` classes in place of `loopmodel` in each of the examples below. See Section 4.4 or Section 4.5 for more details.

Example: examples/automodel/model-loop.py

      # Comparative modeling by the automodel class
      from modeller import *
      from modeller.automodel import *    # Load the automodel class

      log.verbose()
      env = environ()

      # directories for input atom files
      env.io.atom_files_directory = ['.', '../atom_files']

      a = loopmodel(env,
                    alnfile  = 'alignment.ali',     # alignment filename
                    knowns   = '5fd1',              # codes of the templates
                    sequence = '1fdx')              # code of the target
      a.starting_model= 1                 # index of the first model
      a.ending_model  = 1                 # index of the last model
                                          # (determines how many models to calculate)
      a.md_level = None                   # No refinement of model

      a.loop.starting_model = 1           # First loop model
      a.loop.ending_model   = 4           # Last loop model
      a.loop.md_level       = refine.fast # Loop model refinement level

      a.make()                            # do comparative modeling

After generating the standard model(s), a number of loop models are generated for each model, from loopmodel.loop.starting_model to loopmodel.loop.ending_model. Each loop model is written out with the `.BL` extension. See section A.5 for more information.