]> git.donarmstrong.com Git - mothur.git/blobdiff - clustercommand.cpp
added warning about merging with something above cutoff to cluster. working on chimeras
[mothur.git] / clustercommand.cpp
index 93ba1f9b65b8146b666d32debb3df601c046b19a..d14af108d69c36f98617fc2e133c3dcfb537c553 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();
@@ -81,12 +84,13 @@ ClusterCommand::ClusterCommand(string option){
                                }
                                
                                //create cluster
-                               if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, matrix, cutoff); }
-                               else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff); }
-                               else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff);     }
+                               if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
+                               else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
+                               else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff, method);     }
                                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);
@@ -154,7 +158,7 @@ int ClusterCommand::execute(){
 
                        loops++;
 
-                       cluster->update();
+                       cluster->update(cutoff);
                        float dist = matrix->getSmallDist();
                        float rndDist = roundDist(dist, precision);