]> git.donarmstrong.com Git - mothur.git/blobdiff - validcalculator.cpp
added shen calculator
[mothur.git] / validcalculator.cpp
index 8659be3d85f1956f788f13355bea8f9fa67e5052..edcf8c7a33269ece0758903f4d1fc425da558e97 100644 (file)
@@ -18,6 +18,11 @@ ValidCalculators::ValidCalculators() {
                 initialSharedRarefact();
                 initialSummary();
                 initialSharedSummary();
+                initialVennSingle();
+                initialVennShared();
+                initialTreeGroups();
+                initialBoot();
+                initialDistance();
        }
        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";
@@ -42,38 +47,128 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        //is it valid
                        if ((single.find(calculator)) != (single.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid single estimator. Valid single estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
+                       }else { 
+                               cout << 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 << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a shared parameter
                }else if (parameter == "shared") {
                        //is it valid
                        if ((shared.find(calculator)) != (shared.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid shared estimator.  Valid shared estimators are sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
+                       }else { 
+                               cout << 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 << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a rarefaction parameter
                }else if (parameter == "rarefaction") {
                        //is it valid
                        if ((rarefaction.find(calculator)) != (rarefaction.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid rarefaction estimator. Valid rarefaction estimators are rarefaction-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson." << endl; return false; }
+                       }else { 
+                               cout << 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 << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a summary parameter
                }else if (parameter == "summary") {
                        //is it valid
                        if ((summary.find(calculator)) != (summary.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid summary estimator. Valid summary estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
+                       }else { 
+                               cout << 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 << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a sharedsummary parameter
                }else if (parameter == "sharedsummary") {
                        //is it valid
                        if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid sharedsummary estimator. Valid sharedsummary estimators are: sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
-
+                       }else { 
+                               cout << 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 << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                }else if (parameter == "sharedrarefaction") {
                        //is it valid
                        if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid sharedrarefaction estimator. Valid sharedrarefaction estimator is sharedobserved." << endl; return false; }
-               //not a valid paramter
+                       }else { 
+                               cout << 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 << ", ";
+                               }
+                               cout << endl;
+                               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 ";
+                               for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               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 ";
+                               for (it = vennshared.begin(); it != vennshared.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               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 and will be disregarded. Valid estimators are ";
+                               for (it = treegroup.begin(); it != treegroup.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               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 and will be disregarded. Valid estimators are ";
+                               for (it = boot.begin(); it != boot.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
+               }else if (parameter == "distance") {
+                       //is it valid
+                       if ((distance.find(calculator)) != (distance.end())) {
+                               return true;
+                       }else { 
+                               cout << 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++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
+               //not a valid parameter
                }else { return false; }
                
        }
@@ -90,16 +185,27 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
 /********************************************************************/
 void ValidCalculators::initialSingle() {
        try {   
-       
-               single["sobs"]  = "sobs";
-               single["chao"]          = "chao";
-               single["ace"]           = "ace";
-               single["jack"]          = "jack";
-               single["shannon"]       = "shannon";
-               single["npshannon"]     = "npshannon";
-               single["simpson"]       = "simpson";
-               single["bootstrap"]     = "bootstrap";
-               single["default"]       = "default";
+               single["sobs"]          = "sobs";
+               single["chao"]              = "chao";
+               single["ace"]               = "ace";
+               single["jack"]              = "jack";
+               single["shannon"]           = "shannon";
+               single["npshannon"]     = "npshannon";
+               single["simpson"]           = "simpson";
+               single["bergerparker"]  = "bergerparker";
+               single["bootstrap"]     = "bootstrap";
+               single["geometric"]     = "geometric";
+               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";
@@ -114,16 +220,27 @@ void ValidCalculators::initialSingle() {
 /********************************************************************/
 void ValidCalculators::initialShared() {
        try {   
-               shared["sharedChao"]                    = "sharedChao";
-               shared["sharedAce"]                             = "sharedAce";
-               shared["sharedJabund"]                  = "sharedJabund";
-               shared["sharedSorensonAbund"]   = "sharedSorensonAbund";
-               shared["sharedJclass"]                  = "sharedJclass";
-               shared["sharedSorClass"]                = "sharedSorClass";
-               shared["sharedJest"]                    = "sharedJest";
-               shared["sharedSorEst"]                  = "sharedSorEst";
-               shared["SharedThetaYC"]                 = "SharedThetaYC";
-               shared["SharedThetaN"]                  = "SharedThetaN";
+               shared["sharedsobs"]                    = "sharedsobs";
+               shared["sharedchao"]                    = "sharedchao";
+               shared["sharedace"]                             = "sharedace";
+               shared["jabund"]                                = "jabund";
+               shared["sorabund"]                              = "sorabund";
+               shared["jclass"]                                = "jclass";
+               shared["sorclass"]                              = "sorclass";
+               shared["jest"]                                  = "jest";
+               shared["sorest"]                                = "sorest";
+               shared["thetayc"]                               = "thetayc";
+               shared["thetan"]                                = "thetan";
+               shared["kstest"]                                = "kstest";
+               shared["whittaker"]                         = "whittaker";
+               shared["sharednseqs"]                   = "sharednseqs";
+               shared["ochiai"]                                = "ochiai";
+               shared["anderberg"]                             = "anderberg";
+               shared["kulczynski"]                    = "kulczynski";
+               shared["kulczynskicody"]                = "kulczynskicody";
+               shared["lennon"]                                = "lennon";
+               shared["morisitahorn"]                  = "morisitahorn";
+               shared["braycurtis"]                    = "braycurtis";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -147,6 +264,8 @@ void ValidCalculators::initialRarefaction() {
                rarefaction["npshannon"]        = "npshannon";
                rarefaction["simpson"]          = "simpson";
                rarefaction["bootstrap"]        = "bootstrap";
+               rarefaction["nseqs"]            = "nseqs";
+               rarefaction["coverage"]         = "coverage";
                rarefaction["default"]      = "default";
        }
        catch(exception& e) {
@@ -170,7 +289,19 @@ void ValidCalculators::initialSummary() {
                summary["shannon"]              = "shannon";
                summary["npshannon"]    = "npshannon";
                summary["simpson"]              = "simpson";
+               summary["bergerparker"] = "bergerparker";
+               summary["geometric"]    = "geometric";
                summary["bootstrap"]    = "bootstrap";
+               summary["logseries"]    = "logseries";
+               summary["qstat"]        = "qstat";
+               summary["bstick"]       = "bstick";
+               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) {
@@ -186,16 +317,27 @@ void ValidCalculators::initialSummary() {
 /********************************************************************/
 void ValidCalculators::initialSharedSummary() {
        try {   
-               sharedsummary["sharedChao"]                             = "sharedChao";
-               sharedsummary["sharedAce"]                              = "sharedAce";
-               sharedsummary["sharedJabund"]                   = "sharedJabund";
-               sharedsummary["sharedSorensonAbund"]    = "sharedSorensonAbund";
-               sharedsummary["sharedJclass"]                   = "sharedJclass";
-               sharedsummary["sharedSorClass"]                 = "sharedSorClass";
-               sharedsummary["sharedJest"]                             = "sharedJest";
-               sharedsummary["sharedSorEst"]                   = "sharedSorEst";
-               sharedsummary["SharedThetaYC"]                  = "SharedThetaYC";
-               sharedsummary["SharedThetaN"]                   = "SharedThetaN";
+               sharedsummary["sharedsobs"]                             = "sharedsobs";
+               sharedsummary["sharedchao"]                             = "sharedchao";
+               sharedsummary["sharedace"]                              = "sharedace";
+               sharedsummary["jabund"]                                 = "jabund";
+               sharedsummary["sorabund"]                       = "sorabund";
+               sharedsummary["jclass"]                                 = "jclass";
+               sharedsummary["sorclass"]                               = "sorclass";
+               sharedsummary["jest"]                                   = "jest";
+               sharedsummary["sorest"]                                 = "sorest";
+               sharedsummary["thetayc"]                                = "thetayc";
+               sharedsummary["thetan"]                                 = "thetan";
+               sharedsummary["kstest"]                                 = "kstest";
+               sharedsummary["whittaker"]                              = "whittaker";
+               sharedsummary["sharednseqs"]                    = "sharednseqs";
+               sharedsummary["ochiai"]                                 = "ochiai";
+               sharedsummary["anderberg"]                              = "anderberg";
+               sharedsummary["kulczynski"]                             = "kulczynski";
+               sharedsummary["kulczynskicody"]                 = "kulczynskicody";
+               sharedsummary["lennon"]                                 = "lennon";
+               sharedsummary["morisitahorn"]                   = "morisitahorn";
+               sharedsummary["braycurtis"]                             = "braycurtis";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
@@ -214,6 +356,7 @@ void ValidCalculators::initialSharedSummary() {
 void ValidCalculators::initialSharedRarefact() {
        try {   
                sharedrarefaction["sharedobserved"]     = "sharedobserved";
+               sharedrarefaction["sharednseqs"]        = "sharednseqs";
                sharedrarefaction["default"]        = "default";
        }
        catch(exception& e) {
@@ -226,7 +369,173 @@ void ValidCalculators::initialSharedRarefact() {
        }       
 }
 
+
 /********************************************************************/
+void ValidCalculators::initialVennSingle() {
+       try {
+               vennsingle["sobs"]              = "sobs";
+               vennsingle["chao"]                  = "chao";
+               vennsingle["ace"]                       = "ace";
+               vennsingle["jack"]                  = "jack";
+               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";
+               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::initialVennShared() {
+       try {
+               vennshared["sharedsobs"]        = "sharedsobs";
+               vennshared["sharedchao"]        = "sharedchao";
+               vennshared["sharedace"]         = "sharedace";
+               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";
+               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["jclass"]                                     = "jclass";
+               treegroup["sorclass"]                           = "sorclass";
+               treegroup["jest"]                                       = "jest";
+               treegroup["sorest"]                                     = "sorest";
+               treegroup["thetayc"]                            = "thetayc";
+               treegroup["thetan"]                                     = "thetan";
+               treegroup["morisitahorn"]                       = "morisitahorn";
+               treegroup["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";
+               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";
+               exit(1);
+       }       
+}
+/********************************************************************/
+void ValidCalculators::initialBoot() {
+       try {   
+               boot["jabund"]                          = "jabund";
+               boot["sorabund"]                        = "sorabund";
+               boot["jclass"]                          = "jclass";
+               boot["sorclass"]                        = "orclass";
+               boot["jest"]                            = "jest";
+               boot["sorest"]                          = "sorest";
+               boot["thetayc"]                         = "thetayc";
+               boot["thetan"]                          = "thetan";
+               boot["morisitahorn"]            = "morisitahorn";
+               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";
+               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";
+               exit(1);
+       }       
+}
+/********************************************************************/
+void ValidCalculators::initialDistance() {
+       try {   
+               distance["nogaps"]              = "nogaps";
+               distance["eachgap"]             = "eachgap";
+               distance["onegap"]              = "onegap";
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/********************************************************************/
+void ValidCalculators::printCalc(string parameter, ostream& out) {
+       try{
+               out << "The available estimators for calc are ";
+               //are you looking for a calculator for a single parameter
+               if (parameter == "single") {
+                       for (it = single.begin(); it != single.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               //are you looking for a calculator for a shared parameter
+               }else if (parameter == "shared") {
+                       for (it = shared.begin(); it != shared.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               //are you looking for a calculator for a rarefaction parameter
+               }else if (parameter == "rarefaction") {
+                       for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               //are you looking for a calculator for a summary parameter
+               }else if (parameter == "summary") {
+                       for (it = summary.begin(); it != summary.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               //are you looking for a calculator for a sharedsummary parameter
+               }else if (parameter == "sharedsummary") {
+                       for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               }else if (parameter == "sharedrarefaction") {
+                       for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               }else if (parameter == "vennsingle") {
+                       for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               }else if (parameter == "vennshared") {
+                       for (it = vennshared.begin(); it != vennshared.end(); it++) {
+                               out << it->first << ", ";
+                       }
+               }else if (parameter == "treegroup") {
+                       for (it = treegroup.begin(); it != treegroup.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";
+               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);
+       }       
+
+}
+/********************************************************************/