]> git.donarmstrong.com Git - mothur.git/blobdiff - otuhierarchycommand.cpp
sped up align.seqs appending of files
[mothur.git] / otuhierarchycommand.cpp
index 2c71cd56aa8a6341def135ec0a7ddcb092993885..b49af32a76c1cbb2d65ab2a5bf32555a171c5de7 100644 (file)
@@ -9,13 +9,60 @@
 
 #include "otuhierarchycommand.h"
 
+//**********************************************************************************************************************
+vector<string> OtuHierarchyCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"list","label","output","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+OtuHierarchyCommand::OtuHierarchyCommand(){    
+       try {
+               abort = true; calledHelp = true; 
+               vector<string> tempOutNames;
+               outputTypes["otuheirarchy"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "OtuHierarchyCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> OtuHierarchyCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"list","label"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> OtuHierarchyCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 OtuHierarchyCommand::OtuHierarchyCommand(string option) {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                
                //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
@@ -33,6 +80,10 @@ OtuHierarchyCommand::OtuHierarchyCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["otuheirarchy"] = tempOutNames;
+                       
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -105,12 +156,12 @@ OtuHierarchyCommand::~OtuHierarchyCommand(){}
 int OtuHierarchyCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //get listvectors that correspond to labels requested, (or use smart distancing to get closest listvector)
                vector<ListVector> lists = getListVectors();
                
-               if (m->control_pressed) { return 0; }
+               if (m->control_pressed) { outputTypes.clear(); return 0; }
                
                //determine which is little and which is big, putting little first
                if (lists.size() == 2) {
@@ -148,7 +199,7 @@ int OtuHierarchyCommand::execute(){
                //go through each bin in "big" otu and output the bins in "little" otu which created it
                for (int i = 0; i < lists[1].getNumBins(); i++) {
                
-                       if (m->control_pressed) { out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); out.close(); remove(outputFileName.c_str()); return 0; }
                        
                        string names = lists[1].get(i);
                        
@@ -181,11 +232,11 @@ int OtuHierarchyCommand::execute(){
                
                out.close();
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
+               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["otuheirarchy"].push_back(outputFileName); 
                m->mothurOutEndLine();
                
                return 0;