]> git.donarmstrong.com Git - mothur.git/blobdiff - validparameter.cpp
added MPI code, broke up chimera.seqs into 5 separated commands, added parse.sff...
[mothur.git] / validparameter.cpp
index 486316fcdc814307e78e029f9fc7400451cd9393..2d29ee3f668ee1817cb71c82189c2a8c6f61cf00 100644 (file)
 
 ValidParameters::ValidParameters() {
        try {
+               m = MothurOut::getInstance();
                initParameterRanges();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function ValidParameters. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidParameters", "ValidParameters");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function ValidParameters. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -42,11 +39,11 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        }
                }
                if(!valid) {
-                       cout << "'" << parameter << "' is not a valid parameter." << endl;
-                       cout << "The valid parameters are: ";
+                       m->mothurOut(parameter + " is not a valid parameter."); m->mothurOutEndLine();
+                       m->mothurOut("The valid parameters are: ");
                        for(int i = 0; i < numParams-1; i++)
-                               cout << cParams.at(i) << ", ";
-                       cout << "and " << cParams.at(numParams-1) << ".\n";
+                               m->mothurOut(cParams.at(i) + ", ");
+                       m->mothurOut("and " + cParams.at(numParams-1) + ".\n");
                        return false;
                }
                
@@ -77,7 +74,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                                double logNum = log10((double)pVal);
                                double diff = (double)((int)logNum - logNum);
                                if(diff != 0) {
-                                       cout << "The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n";
+                                       m->mothurOut("The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n");
                                        return false;
                                }
                        }
@@ -103,7 +100,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        else if(range.at(4).compare("only") == 0)
                                c = 1;
                        else {
-                               cout << "The range can only be 'between' or 'only' the bounding numbers.\n";
+                               m->mothurOut("The range can only be 'between' or 'only' the bounding numbers.\n");
                                return false;
                        }
                        
@@ -112,7 +109,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        else if(range.at(0).compare(">=") == 0 || range[3].compare("=>") == 0)
                                d = 1;
                        else {
-                               cout << "The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n";
+                               m->mothurOut("The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n");
                                return false;
                        }
                        
@@ -121,7 +118,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        else if(range.at(2).compare("<=") == 0 || range[4].compare("=<") == 0)
                                e = 1;
                        else {
-                               cout << "The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n";
+                               m->mothurOut("The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n");
                                return false;
                        }
                        
@@ -165,25 +162,25 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                        
                        
                        if(!valid) {
-                               cout << "The '" << parameter << "' parameter needs to be ";
+                               m->mothurOut("The '" + parameter + "' parameter needs to be ");
                                if(c == 1)
-                                       cout << "either '" << a << "' or '" << b << "'.\n";
+                                       m->mothurOut("either '" + toString(a) + "' or '" + toString(b) + "'.\n");
                                else {
                                        if(a != piSentinel) {
-                                               cout << ">";
+                                               m->mothurOut(">");
                                                if(d != 0)
-                                                       cout << "=";
-                                               cout << " '" << a << "'";
+                                                       m->mothurOut("=");
+                                               m->mothurOut(" '" + toString(a) + "'");
                                        }
                                        if(b == piSentinel)
-                                               cout << "'.\n";
+                                               m->mothurOut( "'.\n");
                                        else if(a != piSentinel)
-                                               cout << " and ";
+                                               m->mothurOut(" and ");
                                        if(b != piSentinel) {
-                                               cout << "<";
+                                               m->mothurOut("<");
                                                if(e != 0)
-                                                       cout << "=";
-                                               cout << " '" << b << "'.\n";
+                                                       m->mothurOut("=");
+                                               m->mothurOut(" '" + toString(b) + "'.\n");
                                        }
                                }
                                return false;
@@ -192,11 +189,7 @@ bool ValidParameters::isValidParameter(string parameter, vector<string> cParams,
                return true;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidParameters", "isValidParameters");
                exit(1);
        }
 }
@@ -212,10 +205,25 @@ string ValidParameters::validFile(map<string, string> container, string paramete
                
                it = container.find(parameter);
                if(it != container.end()){ //no parameter given
+
                        if(isFile == true) {
+                       
+                       #ifdef USE_MPI  
+                               int pid;
+                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
+                               
+                               if (pid == 0) {
+                       #endif
+
                                ableToOpen = openInputFile(it->second, in);
+
                                if (ableToOpen == 1) { return "not open"; }
                                in.close();
+                               
+                       #ifdef USE_MPI  
+                               }
+                       #endif
+
                        }
                }else { return "not found"; }
                
@@ -223,11 +231,7 @@ string ValidParameters::validFile(map<string, string> container, string paramete
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function validFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function validFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidParameters", "validFile");
                exit(1);
        }
 }
@@ -272,11 +276,7 @@ void ValidParameters::initParameterRanges() {
                parameterRanges["size"] = addParameters(sizeArray, rangeSize);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidParameters", "initParameterRanges");
                exit(1);
        }
 }
@@ -290,11 +290,7 @@ vector<string> ValidParameters::addParameters(string parameters[], int size) {
                return pVector;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidParameters", "addParameters");
                exit(1);
        }
 }