]> git.donarmstrong.com Git - mothur.git/blobdiff - getlistcountcommand.cpp
fixed catchall "clunky" names
[mothur.git] / getlistcountcommand.cpp
index 23c0eaf0dd1852e9406fc600ce09ae8e80042431..78f26047e0debdf3e620b2e0179bfab12fe93354 100644 (file)
@@ -9,16 +9,63 @@
 
 #include "getlistcountcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"list","label","sort","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetListCountCommand::GetListCountCommand(){    
+       try {
+               abort = true; calledHelp = true; 
+               vector<string> tempOutNames;
+               outputTypes["otu"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"list"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 GetListCountCommand::GetListCountCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
-               abort = false;
+               abort = false; calledHelp = false;   
                allLines = 1;
                labels.clear();
                                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
+               if(option == "help") { help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -36,6 +83,10 @@ GetListCountCommand::GetListCountCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["otu"] = tempOutNames;
+               
                        string ranRead = globaldata->getListFile();
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -116,7 +167,7 @@ GetListCountCommand::~GetListCountCommand(){}
 
 int GetListCountCommand::execute(){
        try {
-               if (abort == true) {    return 0;       }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
 
                globaldata->setFormat("list");
                
@@ -152,7 +203,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                                }
                                                        
@@ -173,7 +224,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                                }
                                                                                                        
@@ -216,7 +267,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                        }
                        
@@ -248,7 +299,7 @@ void GetListCountCommand::process(ListVector* list) {
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
                string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
                m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName);
+               outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
                
                m->mothurOut(list->getLabel()); m->mothurOutEndLine();