]> git.donarmstrong.com Git - mothur.git/blobdiff - rarefactsharedcommand.cpp
modified seqerror and qualscores
[mothur.git] / rarefactsharedcommand.cpp
index c0f5ec0c4daba141c9267817836522e0d22c1a3a..ea460c026e4c4ea77684893920b328288d3f9f63 100644 (file)
 #include "sharedsobs.h"
 #include "sharednseqs.h"
 
+//**********************************************************************************************************************
+vector<string> RareFactSharedCommand::getValidParameters(){    
+       try {
+               string Array[] =  {"iters","freq","label","calc","groups", "jumble","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+RareFactSharedCommand::RareFactSharedCommand(){        
+       try {
+               abort = true; calledHelp = true; 
+               vector<string> tempOutNames;
+               outputTypes["sharedrarefaction"] = tempOutNames;
+               outputTypes["sharedr_nseqs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RareFactSharedCommand::getRequiredParameters(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RareFactSharedCommand::getRequiredFiles(){      
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 RareFactSharedCommand::RareFactSharedCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
                
-               abort = false;
+               abort = false; calledHelp = false;   
                allLines = 1;
                labels.clear();
                Estimators.clear();
                Groups.clear();
                                
                //allow user to run help
-               if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
+               if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -41,6 +89,11 @@ RareFactSharedCommand::RareFactSharedCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["sharedrarefaction"] = tempOutNames;
+                       outputTypes["sharedr_nseqs"] = tempOutNames;
+                       
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
                                if (globaldata->getListFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); m->mothurOutEndLine(); abort = true; }
@@ -107,10 +160,10 @@ RareFactSharedCommand::RareFactSharedCommand(string option)  {
                                        if (validCalculator->isValidCalculator("sharedrarefaction", Estimators[i]) == true) { 
                                                if (Estimators[i] == "sharedobserved") { 
                                                        rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
-                                                       outputNames.push_back(fileNameRoot+"shared.rarefaction");
+                                                       outputNames.push_back(fileNameRoot+"shared.rarefaction"); outputTypes["sharedrarefaction"].push_back(fileNameRoot+"shared.rarefaction");
                                                }else if (Estimators[i] == "sharednseqs") { 
                                                        rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+"shared.r_nseqs", "")));
-                                                       outputNames.push_back(fileNameRoot+"shared.r_nseqs");
+                                                       outputNames.push_back(fileNameRoot+"shared.r_nseqs"); outputTypes["sharedr_nseqs"].push_back(fileNameRoot+"shared.r_nseqs");
                                                }
                                        }
                                }
@@ -163,7 +216,7 @@ RareFactSharedCommand::~RareFactSharedCommand(){
 int RareFactSharedCommand::execute(){
        try {
        
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //if the users entered no valid calculators don't execute command
                if (rDisplays.size() == 0) { return 0; }