]> git.donarmstrong.com Git - mothur.git/blobdiff - rarefactsharedcommand.cpp
pat's differences before v.1.8
[mothur.git] / rarefactsharedcommand.cpp
index 022ae65bf8530da954589881fbcfa811adba8082..1d13a569c2026fd800283ad3b8bfc3dd5cd48a93 100644 (file)
@@ -28,7 +28,7 @@ RareFactSharedCommand::RareFactSharedCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"iters","label","calc","groups", "jumble"};
+                       string Array[] =  {"iters","label","calc","groups", "jumble","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -46,6 +46,12 @@ RareFactSharedCommand::RareFactSharedCommand(string option){
                                if (globaldata->getListFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); mothurOutEndLine(); abort = true; }
                                else if (globaldata->getGroupFile() == "") { mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); mothurOutEndLine(); 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  
+                       }
 
                        
                        //check for optional parameter and set defaults
@@ -88,7 +94,7 @@ RareFactSharedCommand::RareFactSharedCommand(string option){
                        
                        if (abort == false) {
                        
-                               string fileNameRoot = getRootName(globaldata->inputFileName);
+                               string fileNameRoot = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
 //                             format = globaldata->getFormat();
 
                                
@@ -188,6 +194,8 @@ int RareFactSharedCommand::execute(){
                        }
                        
                        if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       string saveLabel = lookup[0]->getLabel();
+                       
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                                        lookup = input->getSharedRAbundVectors(lastLabel);
 
@@ -198,6 +206,9 @@ int RareFactSharedCommand::execute(){
 
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
+                                       
+                                       //restore real lastlabel to save below
+                                       lookup[0]->setLabel(saveLabel);
                        }