]> git.donarmstrong.com Git - mothur.git/blobdiff - getrabundcommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / getrabundcommand.cpp
index 2ed5b7be71e13b5369f4cc71aaab72258960d41f..df9754b14219548719305cd53498b5d46b05d42c 100644 (file)
@@ -23,7 +23,7 @@ GetRAbundCommand::GetRAbundCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"label","sorted"};
+                       string Array[] =  {"label","sorted","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -36,6 +36,12 @@ GetRAbundCommand::GetRAbundCommand(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 
+                       string 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->getListFile() == "") { mothurOut("You must read a listfile before you can use the get.rabund command."); mothurOutEndLine(); abort = true; }
                        
@@ -60,7 +66,7 @@ GetRAbundCommand::GetRAbundCommand(string option){
                        }
                                
                        if (abort == false) {
-                               filename = getRootName(globaldata->inputFileName) + "rabund";
+                               filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "rabund";
                                openOutputFile(filename, out);
                        }
                }