This section describes a flowchart of comparative modeling by 
\MODELLER, as implemented in the \Z{model} \TOP\ script. This script is 
also called by \QUANTA\ and \INSIGHT. It can be used for a variety
of modeling tasks, not only for comparative modeling.

Input: script file, alignment file, PDB file(s) for template(s).

Output: 

\begin{tabular}{ll}
 {\tt job.log}     & \logf\ file \\
 {\tt job.ini}     & initial conformation for optimization \\
 {\tt job.rsr}     & restraints file \\
 {\tt job.sch}     & VTFM schedule file \\
 {\tt job.B9999????} & PDB atom file(s) for the model(s) of the target sequence \\
%{\tt job.E9999????}  & energy profiles for the model(s) \\
 {\tt job.V9999????}  & violation profiles for the model(s) \\
 {\tt job.D9999????}  & progress of optimization \\
 {\tt job.BL9999????} & optional loop model(s) \\
 {\tt job.DL9999????} & progress of optimization for loop model(s) \\
 {\tt job.IL9999????} & initial structures for loop model(s) \\
\end{tabular}

The main \MODELLER\ routines used in each step are given in parentheses.

\begin{enumerate}
\item Read and check the alignment between the target sequence and the template
   structures \\ (\C{READ\_\-ALIGNMENT} and \C{CHECK\_\-ALIGNMENT}).

\item Calculate restraints on the target from its alignment with the templates:

   \begin{enumerate}
   \item Generate molecular topology for the target sequence
         (\K{GENERATE\_TOPOLOGY}).
      Disulfides in the target are assigned here from the equivalent 
      disulfides in the templates (\C{PATCH\_SS\_TEMPLATES}). Any user defined 
      patches are also done here (as defined in \TOP\ routine 
      {\tt `special\_patches'}).

   \item Calculate coordinates for atoms that have equivalent atoms in the 
      templates as an average over all templates (\C{TRANSFER\_XYZ})
      (alternatively, read the initial coordinates from a file).

   \item Build the remaining unknown coordinates using internal coordinates 
      from the \CHARMM\ topology library (\C{BUILD\_MODEL}).

   \item Write the initial model to a file with extension {\tt .ini} (\C{WRITE\_MODEL}).

   \item Generate stereochemical, homology-derived, and special restraints
      (\C{MAKE\_RESTRAINTS})
      (alternatively, skip this and assume the restraints file already exists):

      \begin{tabular}{ll}
      stereochemical                      & RESTRAINT\_TYPE = 'bond angle dihedral improper' \\
      mainchain dihedrals $\Phi$, $\Psi$  & RESTRAINT\_TYPE = 'phi-psi\_binormal' \\
      mainchain dihedral $\omega$         & RESTRAINT\_TYPE = 'omega\_dihedral' \\
      sidechain dihedral $\chi_1$         & RESTRAINT\_TYPE = 'chi1\_dihedral' \\
      sidechain dihedral $\chi_2$         & RESTRAINT\_TYPE = 'chi2\_dihedral' \\
      sidechain dihedral $\chi_3$         & RESTRAINT\_TYPE = 'chi3\_dihedral' \\
      sidechain dihedral $\chi_4$         & RESTRAINT\_TYPE = 'chi4\_dihedral' \\
      mainchain CA--CA distance           & RESTRAINT\_TYPE = 'distance' \\
      mainchain N--O distance             & RESTRAINT\_TYPE = 'distance' \\
      sidechain--mainchain distance       & RESTRAINT\_TYPE = 'distance' \\
      sidechain--sidechain distance       & RESTRAINT\_TYPE = 'distance' \\
      block distance restraints           & RESTRAINT\_TYPE = 'distance' \\
      user defined                        & CALL ROUTINE = 'special\_restraints' \\
      non-bonded pairs distance           & RESTRAINT\_TYPE = 'sphere'; calculated on the fly
      \end{tabular}

   \item Write all restraints to a file with extension {\tt .rsr} (\C{WRITE\_RESTRAINTS}).
   \end{enumerate}


\item Calculate model(s) that satisfy the restraints as well as possible.
   For each model:

   \begin{enumerate}
   \item Generate the optimization schedule for the variable target function
         method (VTFM) \\ (\C{MAKE\_\-SCHEDULE}).

   \item Read the initial model (usually from the {\tt .ini} file from 2.d)
         (\C{READ\_MODEL}).

   \item Randomize the initial structure by adding a random number between
      $\pm$\K{DEVIATION} angstroms to all atomic positions (\C{RANDOMIZE\_XYZ}).

   \item optimize the model:
      \begin{itemize}
      \item Partially optimize the model by VTFM; Repeat the following steps 
        as many times as specified by the optimization schedule:

        \begin{itemize}
        \item Read all the restraints by {\tt `rd\_restraints'} (READ\_RESTRAINTS).
        \item Select only the restraints that operate on the atoms that are
          close enough in sequence, as specified by the current step of
          VTFM (\C{PICK\_RESTRAINTS}).
        \item Optimize the model by conjugate gradients, using only currently 
              selected restraints (\C{OPTIMIZE}).
        \end{itemize}

      \item Refine the model by simulated annealing with molecular dynamics,
        if so selected:

       \begin{itemize}
        \item do a short conjugate gradients optimization (\C{OPTIMIZE}).
        \item increase temperature in several steps and do molecular dynamics 
              optimization at each temperature (\C{OPTIMIZE}).
        \item decrease temperature in several steps and do molecular dynamics 
          optimization at each temperature (\C{OPTIMIZE}).
        \item do a short conjugate gradients optimization (\C{OPTIMIZE}).
       \end{itemize}
     \end{itemize}
        
   \item calculate the remaining restraint violations and write them out
      (\C{ENERGY}).

   \item write out the final model to a file with extension {\tt .B9999????} 
    where {\tt ????} indicates the model number (\C{WRITE\_MODEL}). Also write
    out the violations profile. Also write superposed templates and 
    models if so selected by \K{FINAL\_MALIGN3D} = 1.

   \item superpose the models and the templates, if so selected, and write
         them out (\C{EXPAND\_ALIGNMENT}, \C{MALIGN3D}).

   \item do loop modeling if so selected (\Scr{loop}).
   \end{enumerate}
\end{enumerate}
