X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clustercommand.cpp;h=e9df82f6e430b9d11965248882cdc34a650b3a3f;hb=291eaab661778e1fd02c5c22bc388daa97bb1d54;hp=6f6e309331df3caf27dc5d2d0c6d4e19ab246590;hpb=e189982e0a9b7352ad57cc38ccee675f128be22e;p=mothur.git diff --git a/clustercommand.cpp b/clustercommand.cpp index 6f6e309..e9df82f 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -22,7 +22,7 @@ ClusterCommand::ClusterCommand(string option) { else { //valid paramters for this command - string Array[] = {"cutoff","precision","method","showabund","timing","outputdir","inputdir"}; + string Array[] = {"cutoff","precision","method","showabund","timing","hard","outputdir","inputdir"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -56,16 +56,19 @@ ClusterCommand::ClusterCommand(string option) { length = temp.length(); convert(temp, precision); + temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "F"; } + hard = isTrue(temp); + temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; } convert(temp, cutoff); - 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"; } @@ -88,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); } @@ -114,7 +118,7 @@ ClusterCommand::ClusterCommand(string option) { void ClusterCommand::help(){ try { m->mothurOut("The cluster command can only be executed after a successful read.dist command.\n"); - m->mothurOut("The cluster command parameter options are method, cuttoff, precision, showabund and timing. No parameters are required.\n"); + m->mothurOut("The cluster command parameter options are method, cuttoff, hard, precision, showabund and timing. No parameters are required.\n"); m->mothurOut("The cluster command should be in the following format: \n"); m->mothurOut("cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n"); m->mothurOut("The acceptable cluster methods are furthest, nearest and average. If no method is provided then furthest is assumed.\n\n"); @@ -178,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");