X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cluster.cpp;h=6b69e4d5312fcce5db6c084fd42499b64724fb5e;hb=a0f1fca79d2ddfa7ad36b4485039c68b5704fe8d;hp=0a70fbfee99957de6f08315562f9f0d9ac14fee0;hpb=037b7fccc64a5c7d5d5c23a949273a912160a400;p=mothur.git diff --git a/cluster.cpp b/cluster.cpp index 0a70fbf..6b69e4d 100644 --- a/cluster.cpp +++ b/cluster.cpp @@ -13,8 +13,8 @@ /***********************************************************************/ -Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseDistanceMatrix* dm, float c, string f) : -rabund(rav), list(lv), dMatrix(dm), method(f) +Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseDistanceMatrix* dm, float c, string f, float cs) : +rabund(rav), list(lv), dMatrix(dm), method(f), adjust(cs) { try { @@ -85,7 +85,21 @@ void Cluster::update(double& cutOFF){ changed = updateDistance(dMatrix->seqVec[smallCol][j], dMatrix->seqVec[smallRow][i]); dMatrix->updateCellCompliment(smallCol, j); break; - }else if (dMatrix->seqVec[smallCol][j].index < search) { j+=nColCells; } //we don't have a distance for this cell + }else if (dMatrix->seqVec[smallCol][j].index < search) { //we don't have a distance for this cell + if (adjust != -1.0) { //adjust + merged = true; + PDistCell value(search, adjust); //create a distance for the missing value + int location = dMatrix->addCellSorted(smallCol, value); + changed = updateDistance(dMatrix->seqVec[smallCol][location], dMatrix->seqVec[smallRow][i]); + dMatrix->updateCellCompliment(smallCol, location); + nColCells++; + foundCol.push_back(0); //add a new found column + //adjust value + for (int k = foundCol.size()-1; k > location; k--) { foundCol[k] = foundCol[k-1]; } + foundCol[location] = 1; + } + j+=nColCells; + } } } //if not merged it you need it for warning @@ -105,14 +119,20 @@ void Cluster::update(double& cutOFF){ // Special handling for singlelinkage case, not sure whether this // could be avoided for (int i=nColCells-1;i>=0;i--) { - if (foundCol[i] == 0) { - if (method == "average" || method == "weighted") { - if (dMatrix->seqVec[smallCol][i].index != smallRow) { //if you are not hte smallest distance - if (cutOFF > dMatrix->seqVec[smallCol][i].dist) { - cutOFF = dMatrix->seqVec[smallCol][i].dist; - } - } - } + if (foundCol[i] == 0) { + if (adjust != -1.0) { //adjust + PDistCell value(smallCol, adjust); //create a distance for the missing value + changed = updateDistance(dMatrix->seqVec[smallCol][i], value); + dMatrix->updateCellCompliment(smallCol, i); + }else { + if (method == "average" || method == "weighted") { + if (dMatrix->seqVec[smallCol][i].index != smallRow) { //if you are not hte smallest distance + if (cutOFF > dMatrix->seqVec[smallCol][i].dist) { + cutOFF = dMatrix->seqVec[smallCol][i].dist; + } + } + } + } dMatrix->rmCell(smallCol, i); } }