\section{rand\_\-eval.C File Reference}
\label{rand_eval_C}\index{rand_eval.C@{rand\_\-eval.C}}
{\tt \#include $<$fstream.h$>$}\par
{\tt \#include "dynstring.h"}\par
{\tt \#include "dllist.h"}\par
{\tt \#include "constraint\_\-manager.h"}\par
{\tt \#include "constraint\_\-registry.h"}\par
{\tt \#include "globals.h"}\par
{\tt \#include "error\_\-handler.h"}\par


Include dependency graph for rand\_\-eval.C:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=215pt]{rand_eval_C_incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf print\_\-usage} (ostream \&os)
\begin{CompactList}\small\item\em Prints information about usage.\item\end{CompactList}\item 
void {\bf print\_\-help} (ostream \&os)
\begin{CompactList}\small\item\em Prints full help.\item\end{CompactList}\item 
int {\bf main} (int argc, char $\ast$$\ast$argv)
\end{CompactItemize}


\subsection{Function Documentation}
\index{rand_eval.C@{rand\_\-eval.C}!main@{main}}
\index{main@{main}!rand_eval.C@{rand\_\-eval.C}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, char $\ast$$\ast$ {\em argv})}\label{rand_eval_C_a2}




Definition at line 17 of file rand\_\-eval.C.\footnotesize\begin{verbatim}00017                                  {
00018   if(argc < 2)
00019     {            
00020       print_usage(cout);
00021       return 0;
00022     }
00023   
00024   cerr << "Begin: ";
00025   for (int i =0; i < argc; i++){
00026     cerr << argv[i]<<" ";
00027   }
00028   cerr << endl;
00029   
00031   DLList<DynString> ArgList;
00032 
00034   DLList<DynString> ConstraintFileList;
00035 
00037   Molecule * predictedMolecule=0;
00038   
00040   DynString arg;
00041 
00043   ifstream * XmolInputFile=0;
00044 
00045 
00047   ifstream * input=0;
00048 
00050   int argStart = 1;
00051 
00053   DynString BaseFN = "evalenv-output";
00054 
00055   int cycle = 10;
00056   double pert = 0.05;
00057   
00058   // See if the user has specified a parameter file.  It is a 
00059   // parameter file if the first argument does *not* start with
00060   // a dash, '-' (i.e. it is not a flag).
00061   //  
00062   
00063   if(argv[1][0] != '-')
00064     {
00065       // Read in the arguments from the parameter file.  This file should
00066       // contain flags (including their dashes) followed immediately by
00067       // the values associated with them.  Warning: this processing step
00068       // ignores white space!
00069       //
00070       if(!(input = new ifstream(argv[1])))
00071         {
00072           cerr << "Could not open/find parameter file, " << argv[1]
00073                << ", quitting. Try -help option.\n";
00074           return 1;
00075         }
00076       while(!input->eof() && !input->bad())
00077         {
00078           *input >> arg;
00079 
00080           if(arg[0] == '#')
00081             arg.EatLine(*input);
00082           // Ignore lines that begin with a pound, '#', sign:
00083           else
00084             ArgList.AddToBack(arg);
00085         }
00086       ArgList.RemoveFromBack();  // Get rid of the eof character.
00087 
00088       delete input; input=0;
00089       argStart=2;
00090     }
00091 
00092   // Copy the arguments from the command line onto our argument list:
00093   //
00094   for(int a=argStart; a<argc; ++a)
00095     ArgList.AddToBack(DynString(argv[a]));
00096 
00097   while(ArgList)
00098     {
00099       arg = ArgList.RemoveFromFront();
00100 
00101       // Initial molecule file is being specified.
00102       //
00103 
00104       if((arg == DynString("-initial")) ||
00105          (arg == DynString("-init")) ||
00106          (arg == DynString("-i")))
00107         {
00108           // Check to see if we've already read in a molecule:
00109           if(predictedMolecule)
00110             {
00111               cerr << "Warning: More than one file has been supplied for "
00112                    << "the initial molecule.\nWill use the molecule "
00113                    << "specified in the file listed last.\n";
00114               delete predictedMolecule; predictedMolecule=0;
00115             }
00116 
00117           arg = ArgList.RemoveFromFront();  // Get the name of the xmol file.
00118           if((XmolInputFile = new ifstream(arg.GetData())))
00119             {
00120               predictedMolecule = new Molecule;
00121               if(predictedMolecule->readXmol(*XmolInputFile)<1)
00122                 {
00123                   cerr << "Error reading initial molecule.\n";
00124                   delete predictedMolecule; predictedMolecule=0;
00125                 }
00126             }
00127           else
00128             {
00129               cerr << "Could not open initial molecule file, " << arg
00130                    << ", will try default location.\n";
00131             }
00132         }
00133       
00134       else if((arg == DynString("-constraint")) ||
00135               (arg == DynString("-constraints")) ||
00136               (arg == DynString("-c")))
00137         {
00138           // Just add this file to the list of files that contain
00139           // constraints for right now.  We'll read these in once 
00140           // we're sure we have an initial molecule.
00141           //
00142           arg = ArgList.RemoveFromFront();
00143           ConstraintFileList.AddToBack(arg);
00144         }
00145 
00146       else if(arg == DynString("-f") ||
00147               arg == DynString("-filebase"))
00148         {
00149             arg = ArgList.RemoveFromFront();
00150             if (arg[0] != '-'){
00151               BaseFN = arg;
00152             } else {
00153               DIE("Confused by filename ");
00154             }
00155         }
00156 
00157       else if(arg == DynString("-cycle"))
00158         {
00159           arg = ArgList.RemoveFromFront();
00160           if (arg[0] != '-'){
00161             cycle = arg.ToInt();
00162           } else {
00163             DIE("Confused by cycle arg ");
00164           }
00165         }
00166 
00167       else if(arg == DynString("-pert"))
00168         {
00169           arg = ArgList.RemoveFromFront();
00170           if (arg[0] != '-'){
00171             pert = arg.ToDbl();
00172           } else {
00173             DIE("Confused by pert arg ");
00174           }
00175         }
00176 
00177       else if(arg == DynString("-help"))
00178         {
00179           print_help(cout);
00180           return 0;
00181             
00182         }
00183 
00184       // Ignore the bogus parameter.
00185       //
00186       else
00187         {
00188           cerr << "Unknown argument, " << arg << ", given, ignoring.\n";
00189         }
00190     }
00191 
00192   // If we havent read in an initial molecule, we'll check the default
00193   // location for one:
00194   //
00195   if(!predictedMolecule)
00196     {
00197       cerr << "No initial molecule specified, quitting. Try -help option.\n";
00198       return 3;
00199     }
00200 
00201   // Now that we've got an actual molecule, we can create a constraint
00202   // manager and read in the constraints:
00203   //
00204 
00205   ConstraintManager CM(*predictedMolecule);
00206 
00207   int num_read = 0;
00208   
00209   while(ConstraintFileList)
00210     {
00211       // Get the filename and then open the file and then read the
00212       // constraints in using the constraint manager.
00213       arg = ConstraintFileList.RemoveFromFront();
00214       input = new ifstream(arg.GetData());
00215       if(input->good())
00216         {
00217           // Use the registry's routine to read in constraints and
00218           // append them to the constraint manager.
00219           //
00220 
00221           num_read += ConstraintRegistry::readConstraints(*input,CM);
00222           delete input; input=0;
00223         } else {
00224           cerr << "\n\nWhile reading file: " << arg.GetData() << endl;
00225           DIE ("Cannot open file");
00226         }
00227 
00228     }
00229 
00230   if (num_read == 0) {
00231     DIE ("You have no constraints");
00232   }
00233 
00234   jdRand_Eval myeval(CM, XmolInputFile, cycle, pert);
00235   myeval.BaseFN = BaseFN;
00236   myeval.run();
00237   
00238   delete predictedMolecule;
00239   if (XmolInputFile)
00240     {delete XmolInputFile;XmolInputFile =0;}
00241 \end{verbatim}\normalsize 
\index{rand_eval.C@{rand\_\-eval.C}!print_help@{print\_\-help}}
\index{print_help@{print\_\-help}!rand_eval.C@{rand\_\-eval.C}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void print\_\-help (ostream \& {\em os})}\label{rand_eval_C_a1}


Prints full help.



Definition at line 260 of file rand\_\-eval.C.

Referenced by main().\footnotesize\begin{verbatim}00261 {
00262   os    << "\nHELP\n\n";
00263   print_usage(os);
00264   os    << "Additional Options:\n"
00265         << "  -cycle n   # perturb for n cycles\n"
00266         << "  -pert  n    # move each atom up to +/- n Angstoms in each direction\n";
00267 
00268 \end{verbatim}\normalsize 
\index{rand_eval.C@{rand\_\-eval.C}!print_usage@{print\_\-usage}}
\index{print_usage@{print\_\-usage}!rand_eval.C@{rand\_\-eval.C}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void print\_\-usage (ostream \& {\em os})}\label{rand_eval_C_a0}


Prints information about usage.



Definition at line 246 of file rand\_\-eval.C.

Referenced by main(), and print\_\-help().\footnotesize\begin{verbatim}00247 {
00248   os    << "\nUsage: rand_eval <-help> [optionfilename | options] \n\n"
00249         << "Required options:\n"
00250         << "  {-initial | -init | -i} <filename> }\n"
00251         << "     Initial molecule: xmol file\n"
00252         << "  {-constraints | -c}
00253 \end{verbatim}\normalsize 
