]> git.donarmstrong.com Git - mothur.git/blobdiff - summarycommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / summarycommand.cpp
index afb4758a29b3831cd7958583344aa223fec3e223..032282411f60905990f59dc0275259266e86d7e7 100644 (file)
@@ -44,7 +44,7 @@ SummaryCommand::SummaryCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"label","calc","abund","size"};
+                       string Array[] =  {"label","calc","abund","size","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -59,7 +59,13 @@ SummaryCommand::SummaryCommand(string option){
                        
                        //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 summary.single 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
                        // ...at some point should added some additional type checking...
                        label = validParameter.validFile(parameters, "label", false);                   
@@ -133,13 +139,14 @@ int SummaryCommand::execute(){
                
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
-                       string fileNameRoot = getRootName(inputFileNames[p]) + "summary";
+                       string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p])) + "summary";
                        globaldata->inputFileName = inputFileNames[p];
                        
                        if (inputFileNames.size() > 1) {
                                mothurOutEndLine(); mothurOut("Processing group " + groups[p]); mothurOutEndLine(); mothurOutEndLine();
                        }
                        
+                       sumCalculators.clear();
                        
                        validCalculator = new ValidCalculators();