]> git.donarmstrong.com Git - mothur.git/blobdiff - getgroupcommand.cpp
fixed unifrac.weighted
[mothur.git] / getgroupcommand.cpp
index 817331f8ce06a531c447896707951b2e6ffb7b9d..40bfb26c6a21cfd29368720ef91782e8cd638ac6 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "getgroupcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetgroupCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetgroupCommand::GetgroupCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["bootgroup"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "GetgroupCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetgroupCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetgroupCommand::getRequiredFiles(){    
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 GetgroupCommand::GetgroupCommand(string option)  {
        try {
@@ -32,6 +79,10 @@ GetgroupCommand::GetgroupCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["bootgroup"] = tempOutNames;
+                       
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        string outputDir = validParameter.validFile(parameters, "outputdir", false);            if (outputDir == "not found"){  outputDir = "";         }
                        
@@ -40,12 +91,12 @@ GetgroupCommand::GetgroupCommand(string option)  {
                        if (abort == false) {
                                //open shared file
                                sharedfile = globaldata->getSharedFile();
-                               openInputFile(sharedfile, in);
+                               m->openInputFile(sharedfile, in);
                
                                //open output file
-                               if (outputDir == "") { outputDir += hasPath(sharedfile); }
-                               outputFile = outputDir + getRootName(getSimpleName(sharedfile)) + "bootGroups";
-                               openOutputFile(outputFile, out);
+                               if (outputDir == "") { outputDir += m->hasPath(sharedfile); }
+                               outputFile = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "bootGroups";
+                               m->openOutputFile(outputFile, out);
 
                        }
                }
@@ -102,13 +153,13 @@ int GetgroupCommand::execute(){
                        in >> inputData;
                }
                
-               if (m->control_pressed) { in.close();  out.close(); remove(outputFile.c_str());   return 0; }
+               if (m->control_pressed) { outputTypes.clear(); in.close();  out.close(); remove(outputFile.c_str());   return 0; }
 
                if (in.eof() != true) { in >> nextLabel; }
                
                //read the rest of the groups info in
                while ((nextLabel == holdLabel) && (in.eof() != true)) {
-                       if (m->control_pressed) { in.close();  out.close(); remove(outputFile.c_str());   return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); in.close();  out.close(); remove(outputFile.c_str());   return 0; }
                        
                        in >> groupN >> num;
                        count++;
@@ -132,7 +183,7 @@ int GetgroupCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFile); m->mothurOutEndLine();        
+               m->mothurOut(outputFile); m->mothurOutEndLine();        outputNames.push_back(outputFile); outputTypes["bootgroup"].push_back(outputFile);
                m->mothurOutEndLine();
                
                return 0;