X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clustercommand.cpp;h=d14af108d69c36f98617fc2e133c3dcfb537c553;hb=2397df97b12cd5d21ea10dc4248c18a5803ddd41;hp=93ba1f9b65b8146b666d32debb3df601c046b19a;hpb=832d53a9dfac6b1795735eec643d8cf627b0d8e3;p=mothur.git diff --git a/clustercommand.cpp b/clustercommand.cpp index 93ba1f9..d14af10 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -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 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);