]> git.donarmstrong.com Git - mothur.git/blobdiff - clustercommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / clustercommand.cpp
index 93ba1f9b65b8146b666d32debb3df601c046b19a..9d09d2cbe465da6531bbf720f0fd7d89aec08bce 100644 (file)
@@ -21,7 +21,7 @@ ClusterCommand::ClusterCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"cutoff","precision","method","showabund","timing"};
+                       string Array[] =  {"cutoff","precision","method","showabund","timing","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -36,6 +36,9 @@ ClusterCommand::ClusterCommand(string option){
                                }
                        }
                        
+                       //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 = "";         }
+                       
                        //error checking to make sure they read a distance file
                        if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
                                mothurOut("Before you use the cluster command, you first need to read in a distance matrix."); mothurOutEndLine();
@@ -85,8 +88,9 @@ ClusterCommand::ClusterCommand(string option){
                                else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff); }
                                else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff);     }
                                tag = cluster->getTag();
-
-                               fileroot = getRootName(globaldata->inputFileName);
+                               
+                               if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
+                               fileroot = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
                        
                                openOutputFile(fileroot+ tag + ".sabund",       sabundFile);
                                openOutputFile(fileroot+ tag + ".rabund",       rabundFile);