]> git.donarmstrong.com Git - mothur.git/blobdiff - clustercommand.cpp
1.12.0
[mothur.git] / clustercommand.cpp
index 9ed67e04433edecd93262c1824732edbb3cd186c..e9df82f6e430b9d11965248882cdc34a650b3a3f 100644 (file)
@@ -62,13 +62,13 @@ ClusterCommand::ClusterCommand(string option)  {
                        temp = validParameter.validFile(parameters, "cutoff", false);
                        if (temp == "not found") { temp = "10"; }
                        convert(temp, cutoff); 
-                       if (!hard) {    cutoff += (5 / (precision * 10.0));  }
+                       cutoff += (5 / (precision * 10.0));  
                        
                        method = validParameter.validFile(parameters, "method", false);
                        if (method == "not found") { method = "furthest"; }
                        
-                       if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
-                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
+                       if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { }
+                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest, average, and weighted."); m->mothurOutEndLine(); abort = true; }
 
                        showabund = validParameter.validFile(parameters, "showabund", false);
                        if (showabund == "not found") { showabund = "T"; }
@@ -91,6 +91,7 @@ ClusterCommand::ClusterCommand(string option)  {
                                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);     }
+                               else if(method == "weighted"){  cluster = new WeightedLinkage(rabund, list, matrix, cutoff, method);    }
                                tag = cluster->getTag();
                                
                                if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
@@ -181,7 +182,12 @@ int ClusterCommand::execute(){
                        cluster->update(cutoff);
        
                        float dist = matrix->getSmallDist();
-                       float rndDist = roundDist(dist, precision);
+                       float rndDist;
+                       if (hard) {
+                               rndDist = ceilDist(dist, precision); 
+                       }else{
+                               rndDist = roundDist(dist, precision); 
+                       }
 
                        if(previousDist <= 0.0000 && dist != previousDist){
                                printData("unique");