X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mgclustercommand.cpp;h=b982b8d1deb3cbc51716cf74339b8dcaea5d136d;hb=b1d143351bcd1b3b4a06ec525c386f161579ee32;hp=fd2671750afa59b42fb3015c182df778b8871583;hpb=7bf9a81bba76538ecaf351ae208de3da4bf1b6dd;p=mothur.git diff --git a/mgclustercommand.cpp b/mgclustercommand.cpp index fd26717..b982b8d 100644 --- a/mgclustercommand.cpp +++ b/mgclustercommand.cpp @@ -235,6 +235,8 @@ int MGClusterCommand::execute(){ return 0; } + double saveCutoff = cutoff; + if (!hclusterWanted) { //get distmatrix and overlap SparseMatrix* distMatrix = read->getDistMatrix(); @@ -373,6 +375,11 @@ int MGClusterCommand::execute(){ seqs = hcluster->getSeqs(); + //to account for cutoff change in average neighbor + if (seqs.size() != 0) { + if (seqs[0].dist > cutoff) { break; } + } + if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); @@ -386,7 +393,7 @@ int MGClusterCommand::execute(){ if (seqs[i].seq1 != seqs[i].seq2) { - hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist); + cutoff = hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist); if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; @@ -491,6 +498,13 @@ int MGClusterCommand::execute(){ m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); + if (saveCutoff != cutoff) { + if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); } + else { saveCutoff = m->roundDist(saveCutoff, precision); } + + m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); + } + //set list file as new current listfile string current = ""; itTypes = outputTypes.find("list");