]> git.donarmstrong.com Git - mothur.git/blobdiff - validcalculator.cpp
added cluster.fragments command as well as the nseqs parameter to the venn command
[mothur.git] / validcalculator.cpp
index f6fe280a86474ea35e78a18245ac24a0ba5e5349..bc8c4b8d7ab4b753cfa3f75a7c7da0b8ba740bc0 100644 (file)
@@ -12,6 +12,8 @@
 /********************************************************************/
 ValidCalculators::ValidCalculators() {
        try {
+                m = MothurOut::getInstance();
+               
                 initialSingle();
                 initialShared();
                 initialRarefaction();
@@ -22,15 +24,14 @@ ValidCalculators::ValidCalculators() {
                 initialVennShared();
                 initialTreeGroups();
                 initialBoot();
+                initialDistance();
+                initialMatrix();
+                initialHeat();
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "ValidCalculator");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }                
 }
 
 /********************************************************************/
@@ -47,11 +48,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((single.find(calculator)) != (single.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
                                for (it = single.begin(); it != single.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a shared parameter
                }else if (parameter == "shared") {
@@ -59,11 +60,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((shared.find(calculator)) != (shared.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ";
+                               m->mothurOut(calculator +  " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ");
                                for (it = shared.begin(); it != shared.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a rarefaction parameter
                }else if (parameter == "rarefaction") {
@@ -71,11 +72,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((rarefaction.find(calculator)) != (rarefaction.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
                                for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a summary parameter
                }else if (parameter == "summary") {
@@ -83,11 +84,11 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((summary.find(calculator)) != (summary.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
                                for (it = summary.begin(); it != summary.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                //are you looking for a calculator for a sharedsummary parameter
                }else if (parameter == "sharedsummary") {
@@ -95,79 +96,108 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator +  " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
                                for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                }else if (parameter == "sharedrarefaction") {
                        //is it valid
                        if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
+                               m->mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
                                for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                }else if (parameter == "vennsingle") {
                        //is it valid
                        if ((vennsingle.find(calculator)) != (vennsingle.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
                                for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                }else if (parameter == "vennshared") {
                        //is it valid
                        if ((vennshared.find(calculator)) != (vennshared.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
                                for (it = vennshared.begin(); it != vennshared.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                }else if (parameter == "treegroup") {
                        //is it valid
                        if ((treegroup.find(calculator)) != (treegroup.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the tree.shared command in shared mode and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
                                for (it = treegroup.begin(); it != treegroup.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
+                               }
+                               m->mothurOutEndLine();
+                               return false; }
+               }else if (parameter == "matrix") {
+                       //is it valid
+                       if ((matrix.find(calculator)) != (matrix.end())) {
+                               return true;
+                       }else { 
+                               m->mothurOut(calculator +  " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
+                               for (it = matrix.begin(); it != matrix.end(); it++) {
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
+                               return false; }
+               }else if (parameter == "heat") {
+                       //is it valid
+                       if ((heat.find(calculator)) != (heat.end())) {
+                               return true;
+                       }else { 
+                               m->mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
+                               for (it = heat.begin(); it != heat.end(); it++) {
+                                       m->mothurOut(it->first + ", ");
+                               }
+                               m->mothurOutEndLine();
                                return false; }
                }else if (parameter == "boot") {
                        //is it valid
                        if ((boot.find(calculator)) != (boot.end())) {
                                return true;
                        }else { 
-                               cout << calculator << " is not a valid estimator for the bootstrap.shared command in shared mode and will be disregarded. Valid estimators are ";
+                               m->mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
                                for (it = boot.begin(); it != boot.end(); it++) {
-                                       cout << it->first << ", ";
+                                       m->mothurOut(it->first + ", ");
+                               }
+                               m->mothurOutEndLine();
+                               return false; }
+               }else if (parameter == "distance") {
+                       //is it valid
+                       if ((distance.find(calculator)) != (distance.end())) {
+                               return true;
+                       }else { 
+                               m->mothurOut(calculator +  " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
+                               for (it = distance.begin(); it != distance.end(); it++) {
+                                       m->mothurOut(it->first + ", ");
                                }
-                               cout << endl;
+                               m->mothurOutEndLine();
                                return false; }
                //not a valid parameter
                }else { return false; }
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "isValidCalculator");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -179,26 +209,31 @@ void ValidCalculators::initialSingle() {
                single["jack"]              = "jack";
                single["shannon"]           = "shannon";
                single["npshannon"]     = "npshannon";
+               single["shannoneven"]   = "shannoneven";
+               single["smithwilson"]   = "smithwilson";
+               single["heip"]                  = "heip";
                single["simpson"]           = "simpson";
+               single["simpsoneven"]   = "simpsoneven";
+               single["invsimpson"]    = "invsimpson";
                single["bergerparker"]  = "bergerparker";
                single["bootstrap"]     = "bootstrap";
                single["geometric"]     = "geometric";
-               single["logseries"]         = "logseries";
+               single["logseries"]             = "logseries";
                single["qstat"]         = "qstat";
                single["bstick"]        = "bstick";
                single["goodscoverage"] = "goodscoverage";
                single["nseqs"]                 = "nseqs";
                single["coverage"]              = "coverage";
+               single["efron"]         = "efron";
+               single["boneh"]         = "boneh";
+               single["solow"]         = "solow";
+               single["shen"]          = "shen";
                single["default"]           = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialSingle");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -208,7 +243,7 @@ void ValidCalculators::initialShared() {
                shared["sharedchao"]                    = "sharedchao";
                shared["sharedace"]                             = "sharedace";
                shared["jabund"]                                = "jabund";
-               shared["sorabund"]                      = "sorabund";
+               shared["sorabund"]                              = "sorabund";
                shared["jclass"]                                = "jclass";
                shared["sorclass"]                              = "sorclass";
                shared["jest"]                                  = "jest";
@@ -228,13 +263,9 @@ void ValidCalculators::initialShared() {
                shared["default"]                   = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialShared");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -245,21 +276,22 @@ void ValidCalculators::initialRarefaction() {
                rarefaction["ace"]                      = "ace";
                rarefaction["jack"]                     = "jack";
                rarefaction["shannon"]          = "shannon";
+               rarefaction["smithwilson"]      = "smithwilson";
+               rarefaction["heip"]                     = "heip";
                rarefaction["npshannon"]        = "npshannon";
+               rarefaction["shannoneven"]      = "shannoneven";
                rarefaction["simpson"]          = "simpson";
+               rarefaction["invsimpson"]       = "invsimpson";
+               rarefaction["simpsoneven"]      = "simpsoneven";
                rarefaction["bootstrap"]        = "bootstrap";
                rarefaction["nseqs"]            = "nseqs";
                rarefaction["coverage"]         = "coverage";
                rarefaction["default"]      = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialRarefaction");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -271,8 +303,13 @@ void ValidCalculators::initialSummary() {
                summary["ace"]                  = "ace";
                summary["jack"]                 = "jack";
                summary["shannon"]              = "shannon";
+               summary["heip"]                 = "heip";
+               summary["shannoneven"]  = "shannoneven";
+               summary["smithwilson"]  = "smithwilson";
+               summary["invsimpson"]   = "invsimpson";
                summary["npshannon"]    = "npshannon";
                summary["simpson"]              = "simpson";
+               summary["simpsoneven"]  = "simpsoneven";
                summary["bergerparker"] = "bergerparker";
                summary["geometric"]    = "geometric";
                summary["bootstrap"]    = "bootstrap";
@@ -282,16 +319,16 @@ void ValidCalculators::initialSummary() {
                summary["nseqs"]                = "nseqs";
                summary["goodscoverage"]= "goodscoverage";
                summary["coverage"]             = "coverage";
+               summary["efron"]        = "efron";
+               summary["boneh"]        = "boneh";
+               summary["solow"]        = "solow";
+               summary["shen"]         = "shen";
                summary["default"]          = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialSummary");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -321,13 +358,9 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialSharedSummary");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -340,13 +373,9 @@ void ValidCalculators::initialSharedRarefact() {
                sharedrarefaction["default"]        = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -360,13 +389,9 @@ void ValidCalculators::initialVennSingle() {
                vennsingle["default"]           = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialVennSingle");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
@@ -378,20 +403,16 @@ void ValidCalculators::initialVennShared() {
                vennshared["default"]           = "default";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialVennShared");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /********************************************************************/
 void ValidCalculators::initialTreeGroups() {
        try {   
                treegroup["jabund"]                                     = "jabund";
-               treegroup["sorabund"]                   = "sorabund";
+               treegroup["sorabund"]                           = "sorabund";
                treegroup["jclass"]                                     = "jclass";
                treegroup["sorclass"]                           = "sorclass";
                treegroup["jest"]                                       = "jest";
@@ -399,22 +420,58 @@ void ValidCalculators::initialTreeGroups() {
                treegroup["thetayc"]                            = "thetayc";
                treegroup["thetan"]                                     = "thetan";
                treegroup["morisitahorn"]                       = "morisitahorn";
-               treegroup["braycurtis"]                 = "braycurtis";
+               treegroup["braycurtis"]                         = "braycurtis";
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ValidCalculator", "initialTreeGroups");
+               exit(1);
+       }
+}
+/********************************************************************/
+void ValidCalculators::initialHeat() {
+       try {   
+               heat["jabund"]                          = "jabund";
+               heat["sorabund"]                        = "sorabund";
+               heat["jclass"]                          = "jclass";
+               heat["sorclass"]                        = "sorclass";
+               heat["jest"]                            = "jest";
+               heat["sorest"]                          = "sorest";
+               heat["thetayc"]                         = "thetayc";
+               heat["thetan"]                          = "thetan";
+               heat["morisitahorn"]            = "morisitahorn";
+               heat["braycurtis"]                      = "braycurtis";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialHeat");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+}
+
+/********************************************************************/
+void ValidCalculators::initialMatrix() {
+       try {   
+               matrix["jabund"]                                = "jabund";
+               matrix["sorabund"]                              = "sorabund";
+               matrix["jclass"]                                = "jclass";
+               matrix["sorclass"]                              = "sorclass";
+               matrix["jest"]                                  = "jest";
+               matrix["sorest"]                                = "sorest";
+               matrix["thetayc"]                               = "thetayc";
+               matrix["thetan"]                                = "thetan";
+               matrix["morisitahorn"]                  = "morisitahorn";
+               matrix["braycurtis"]                    = "braycurtis";
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ValidCalculator", "initialMatrix");
                exit(1);
-       }       
+       }
 }
+
 /********************************************************************/
 void ValidCalculators::initialBoot() {
        try {   
                boot["jabund"]                          = "jabund";
-               boot["sorabund"]                = "sorabund";
+               boot["sorabund"]                        = "sorabund";
                boot["jclass"]                          = "jclass";
                boot["sorclass"]                        = "orclass";
                boot["jest"]                            = "jest";
@@ -425,13 +482,21 @@ void ValidCalculators::initialBoot() {
                boot["braycurtis"]                      = "braycurtis";
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "initialBoot");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+}
+/********************************************************************/
+void ValidCalculators::initialDistance() {
+       try {   
+               distance["nogaps"]              = "nogaps";
+               distance["eachgap"]             = "eachgap";
+               distance["onegap"]              = "onegap";
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ValidCalculator", "initialDistance");
                exit(1);
-       }       
+       }
 }
 
 /********************************************************************/
@@ -479,22 +544,30 @@ void ValidCalculators::printCalc(string parameter, ostream& out) {
                        for (it = treegroup.begin(); it != treegroup.end(); it++) {
                                out << it->first << ", ";
                        }
+               }else if (parameter == "matrix") {
+                       for (it = matrix.begin(); it != matrix.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               }else if (parameter == "heat") {
+                       for (it = heat.begin(); it != heat.end(); it++) {
+                               out << it->first << ", ";
+                       }
                }else if (parameter == "boot") {
                        for (it = boot.begin(); it != boot.end(); it++) {
                                out << it->first << ", ";
                        }
+               }else if (parameter == "distance") {
+                       for (it = distance.begin(); it != distance.end(); it++) {
+                               out << it->first << ", ";
+                       }
                }
+
                out << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "ValidCalculator", "printCalc");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-
 }
 /********************************************************************/