]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimonycommand.cpp
added name option to read.tree for use in unifrac and parimony commands
[mothur.git] / parsimonycommand.cpp
index 6df2debe877bc0d594949ad3f62249f3912f76eb..da997c13b0c150369e15d94ccabb95f8dc3b8d26 100644 (file)
@@ -21,7 +21,7 @@ ParsimonyCommand::ParsimonyCommand(string option) {
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"random","groups","iters"};
+                       string Array[] =  {"random","groups","iters","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -41,11 +41,14 @@ ParsimonyCommand::ParsimonyCommand(string option) {
                                if (globaldata->gTree.size() == 0) {
                                        mothurOut("You must read a treefile and a groupfile or set the randomtree parameter to the output filename you wish, before you may execute the parsimony command."); mothurOutEndLine(); abort = true;  }
                        }
-                                               
+                       
+                       //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 = ""; }
+                       
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
                        groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
+                       if (groups == "not found") { groups = ""; globaldata->Groups.clear(); }
                        else { 
                                splitAtDash(groups, Groups);
                                globaldata->Groups = Groups;
@@ -60,18 +63,23 @@ ParsimonyCommand::ParsimonyCommand(string option) {
                                if (randomtree == "") { 
                                        T = globaldata->gTree;
                                        tmap = globaldata->gTreemap;
-                                       output = new ColumnFile(globaldata->getTreeFile()  +  ".parsimony", itersString);
-                                       sumFile = globaldata->getTreeFile() + ".psummary";
+                                       
+                                       if(outputDir == "") { outputDir += hasPath(globaldata->getTreeFile()); }
+                                       output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile())  +  ".parsimony", itersString);
+                                       
+                                       sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".psummary";
                                        openOutputFile(sumFile, outSum);
                                }else { //user wants random distribution
                                        savetmap = globaldata->gTreemap;
                                        getUserInput();
-                                       output = new ColumnFile(randomtree, itersString);
+                                       
+                                       if(outputDir == "") { outputDir += hasPath(randomtree); }
+                                       output = new ColumnFile(outputDir+ getSimpleName(randomtree), itersString);
                                }
                                
                                //set users groups to analyze
                                util = new SharedUtil();
-                               util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted");   //sets the groups the user wants to analyze
+                               util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "parsimony");    //sets the groups the user wants to analyze
                                util->getCombos(groupComb, globaldata->Groups, numComp);
                                
                                if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }