]> git.donarmstrong.com Git - mothur.git/blobdiff - bootstrapsharedcommand.cpp
added warning about merging with something above cutoff to cluster. working on chimeras
[mothur.git] / bootstrapsharedcommand.cpp
index 0f758c15a0eafc98d620d2fb37980be6f221a767..bfd3e984f28208d37e49f22403ad59647af38e7f 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; }
@@ -224,6 +231,7 @@ int BootSharedCommand::execute(){
                        
                        //you have a label the user want that is smaller than this label and the last label has not already been processed
                        if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               string saveLabel = order->getLabel();
                                
                                delete order;
                                order = input->getSharedOrderVector(lastLabel);                                                                                                 
@@ -232,6 +240,9 @@ int BootSharedCommand::execute(){
 
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
+                               
+                               //restore real lastlabel to save below
+                               order->setLabel(saveLabel);
                        }
                        
                        
@@ -369,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]));
                                }
                                
@@ -442,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 = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
                                        consensus = new ConcensusCommand(filename);
                                        consensus->execute();
                                        delete consensus;