]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimonycommand.cpp
finished wrapper for catchall
[mothur.git] / parsimonycommand.cpp
index b87e9c0b1ea0f5e84cbdf87a341c2fc6d393699d..3d6818b30bac00f2a7137e2f158cb0e415106a9b 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "parsimonycommand.h"
 
+//**********************************************************************************************************************
+vector<string> ParsimonyCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"random","groups","iters","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ParsimonyCommand::ParsimonyCommand(){  
+       try {
+               abort = true;
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["parsimony"] = tempOutNames;
+               outputTypes["psummary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParsimonyCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParsimonyCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /***********************************************************/
 ParsimonyCommand::ParsimonyCommand(string option)  {
        try {
@@ -34,6 +82,11 @@ ParsimonyCommand::ParsimonyCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["parsimony"] = tempOutNames;
+                       outputTypes["psummary"] = tempOutNames;
+                       
                        randomtree = validParameter.validFile(parameters, "random", false);             if (randomtree == "not found") { randomtree = ""; }
                        
                        //are you trying to use parsimony without reading a tree or saying you want random distribution
@@ -50,7 +103,7 @@ ParsimonyCommand::ParsimonyCommand(string option)  {
                        groups = validParameter.validFile(parameters, "groups", false);                 
                        if (groups == "not found") { groups = ""; globaldata->Groups.clear(); }
                        else { 
-                               splitAtDash(groups, Groups);
+                               m->splitAtDash(groups, Groups);
                                globaldata->Groups = Groups;
                        }
                                
@@ -64,20 +117,23 @@ ParsimonyCommand::ParsimonyCommand(string option)  {
                                        T = globaldata->gTree;
                                        tmap = globaldata->gTreemap;
                                        
-                                       if(outputDir == "") { outputDir += hasPath(globaldata->getTreeFile()); }
-                                       output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile())  +  ".parsimony", itersString);
-                                       outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile())  +  ".parsimony");
+                                       if(outputDir == "") { outputDir += m->hasPath(globaldata->getTreeFile()); }
+                                       output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile())  +  ".parsimony", itersString);
+                                       outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  +  ".parsimony");
+                                       outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  +  ".parsimony");
                                        
-                                       sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".psummary";
-                                       openOutputFile(sumFile, outSum);
+                                       sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".psummary";
+                                       m->openOutputFile(sumFile, outSum);
                                        outputNames.push_back(sumFile);
+                                       outputTypes["psummary"].push_back(sumFile);
                                }else { //user wants random distribution
                                        savetmap = globaldata->gTreemap;
                                        getUserInput();
                                        
-                                       if(outputDir == "") { outputDir += hasPath(randomtree); }
-                                       output = new ColumnFile(outputDir+ getSimpleName(randomtree), itersString);
-                                       outputNames.push_back(outputDir+ getSimpleName(randomtree));
+                                       if(outputDir == "") { outputDir += m->hasPath(randomtree); }
+                                       output = new ColumnFile(outputDir+ m->getSimpleName(randomtree), itersString);
+                                       outputNames.push_back(outputDir+ m->getSimpleName(randomtree));
+                                       outputTypes["parsimony"].push_back(outputDir+ m->getSimpleName(randomtree));
                                }
                                
                                //set users groups to analyze
@@ -134,7 +190,7 @@ int ParsimonyCommand::execute() {
                if (m->control_pressed) { 
                        delete reading; delete pars; delete util; delete output;
                        if (randomtree == "") {  outSum.close();  }
-                       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();
                        globaldata->Groups.clear();
                        return 0;
                }
@@ -158,7 +214,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output;
                                        if (randomtree == "") {  outSum.close();  }
-                                       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();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -196,7 +252,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output; delete randT;
                                        if (randomtree == "") {  outSum.close();  }
-                                       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();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -233,7 +289,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output; delete randT;
                                        globaldata->gTreemap = savetmap; 
-                                       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();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -245,7 +301,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output; delete randT;
                                        globaldata->gTreemap = savetmap; 
-                                       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();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -302,7 +358,7 @@ int ParsimonyCommand::execute() {
                                delete reading; delete pars; delete util; delete output;
                                if (randomtree == "") {  outSum.close();  }
                                else { globaldata->gTreemap = savetmap; }
-                               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();
                                globaldata->Groups.clear();
                                return 0;
                }
@@ -327,7 +383,7 @@ int ParsimonyCommand::execute() {
                
                if (m->control_pressed) { 
                        delete pars; delete util; delete output;
-                       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;
                }