]> git.donarmstrong.com Git - mothur.git/blobdiff - collectcommand.cpp
added read.shared, broke up globaldata a bit
[mothur.git] / collectcommand.cpp
index 4687c6e8dcb35fa3b19296f2fe5cc0d39745d582..0f622c49b2a30632f53e4fa3ec0dfc3196113374 100644 (file)
@@ -27,25 +27,32 @@ CollectCommand::CollectCommand(){
                string fileNameRoot;
                fileNameRoot = getRootName(globaldata->inputFileName);
                int i;
-               for (i=0; i<globaldata->singleEstimators.size(); i++) {
-                       if (globaldata->singleEstimators[i] == "sobs") { 
-                               cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
-                       }else if (globaldata->singleEstimators[i] == "chao") { 
-                               cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
-                       }else if (globaldata->singleEstimators[i] == "ace") { 
-                               cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
-                       }else if (globaldata->singleEstimators[i] == "jack") { 
-                               cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
-                       }else if (globaldata->singleEstimators[i] == "shannon") { 
-                               cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
-                       }else if (globaldata->singleEstimators[i] == "npshannon") { 
-                               cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
-                       }else if (globaldata->singleEstimators[i] == "simpson") { 
-                               cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
-                       }else if (globaldata->singleEstimators[i] == "bootstrap") { 
-                               cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+               validCalculator = new ValidCalculators();
+               
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("single", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "sobs") { 
+                                       cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
+                               }else if (globaldata->Estimators[i] == "chao") { 
+                                       cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
+                               }else if (globaldata->Estimators[i] == "ace") { 
+                                       cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
+                               }else if (globaldata->Estimators[i] == "jack") { 
+                                       cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
+                               }else if (globaldata->Estimators[i] == "shannon") { 
+                                       cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
+                               }else if (globaldata->Estimators[i] == "npshannon") { 
+                                       cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
+                               }else if (globaldata->Estimators[i] == "simpson") { 
+                                       cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
+                               }else if (globaldata->Estimators[i] == "bootstrap") { 
+                                       cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+                               }
                        }
                }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -72,6 +79,10 @@ CollectCommand::~CollectCommand(){
 int CollectCommand::execute(){
        try {
                int count = 1;
+               
+               //if the users entered no valid calculators don't execute command
+               if (cDisplays.size() == 0) { return 0; }
+
                read = new ReadPhilFile(globaldata->inputFileName);     
                read->read(&*globaldata);