]> git.donarmstrong.com Git - mothur.git/blobdiff - bootstrapsharedcommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / bootstrapsharedcommand.cpp
index 1b682c78e3471fe7b4fef8528e8d74243374cd21..4f4488085a8754b731ca6c742ee43f7b0dc690c4 100644 (file)
@@ -36,7 +36,7 @@ BootSharedCommand::BootSharedCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"label","calc","groups","iters"};
+                       string Array[] =  {"label","calc","groups","iters","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -49,6 +49,13 @@ BootSharedCommand::BootSharedCommand(string option){
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //if the user changes the output directory command factory will send this info to us in the output parameter 
+                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
+                               outputDir = ""; 
+                               outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it  
+                       }
+
+                       
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
                                if (globaldata->getListFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the bootstrap.shared command."); mothurOutEndLine(); abort = true; }
@@ -373,12 +380,11 @@ void BootSharedCommand::process(SharedOrderVector* order) {
        try{
                                EstOutput data;
                                vector<SharedRAbundVector*> subset;
-                               
-                               
+                                                               
                                //open an ostream for each calc to print to
                                for (int z = 0; z < treeCalculators.size(); z++) {
                                        //create a new filename
-                                       outputFile = getRootName(globaldata->inputFileName) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
+                                       outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
                                        openOutputFile(outputFile, *(out[z]));
                                }
                                
@@ -446,7 +452,7 @@ void BootSharedCommand::process(SharedOrderVector* order) {
                                        //set global data to calc trees
                                        globaldata->gTree = trees[k];
                                        
-                                       string filename = getRootName(globaldata->inputFileName) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
+                                       string filename = getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
                                        consensus = new ConcensusCommand(filename);
                                        consensus->execute();
                                        delete consensus;