]> git.donarmstrong.com Git - mothur.git/blobdiff - matrixoutputcommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / matrixoutputcommand.cpp
index 5069e0f07684391033c7c1e2b7595dca9b18e30f..fb74875159a0aabe98e8ea79a540802d25ca2f21 100644 (file)
@@ -36,7 +36,7 @@ MatrixOutputCommand::MatrixOutputCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"label","calc","groups"};
+                       string Array[] =  {"label","calc","groups","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -49,6 +49,12 @@ MatrixOutputCommand::MatrixOutputCommand(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 dist.shared command."); mothurOutEndLine(); abort = true; }
@@ -309,7 +315,7 @@ void MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                                                }
                                        }
                                        
-                                       exportFileName = getRootName(globaldata->inputFileName) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".dist";
+                                       exportFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".dist";
                                        openOutputFile(exportFileName, out);
                                        printSims(out);
                                        out.close();