]> git.donarmstrong.com Git - mothur.git/blobdiff - collectcommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / collectcommand.cpp
index beb70ebe9c7c82d84ab7c21cd43bc3e7a154eb50..a31883cf3c65aabf3955d12191b91b9ad9fe050c 100644 (file)
@@ -44,7 +44,7 @@ CollectCommand::CollectCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"freq","label","calc","abund","size"};
+                       string Array[] =  {"freq","label","calc","abund","size","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -57,6 +57,9 @@ CollectCommand::CollectCommand(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 = "";         }
+                       
                        //make sure the user has already run the read.otu command
                        if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund, rabund or shared file before you can use the collect.single command."); mothurOutEndLine(); abort = true; }
                        
@@ -136,7 +139,8 @@ int CollectCommand::execute(){
                
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
-                       string fileNameRoot = getRootName(inputFileNames[p]);
+                       if (outputDir == "") { outputDir += hasPath(inputFileNames[p]); }
+                       string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
                        globaldata->inputFileName = inputFileNames[p];
                        
                        if (inputFileNames.size() > 1) {