X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cluster.cpp;h=a766e08d47b4af7a46d8093323cb795d57d6aa78;hb=6e8fce385a566f51350274309503d7405e5b9f35;hp=e2d307e1bfbce54162b55a7368b58180205f87e5;hpb=fdc1f6eaf544f695fc1511f24bddd7e6069c33ba;p=mothur.git diff --git a/cluster.cpp b/cluster.cpp index e2d307e..a766e08 100644 --- a/cluster.cpp +++ b/cluster.cpp @@ -17,6 +17,7 @@ Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string f) : rabund(rav), list(lv), dMatrix(dm), method(f) { + try { /* cout << "sizeof(MatData): " << sizeof(MatData) << endl; cout << "sizeof(PCell*): " << sizeof(PCell*) << endl; @@ -50,19 +51,28 @@ rabund(rav), list(lv), dMatrix(dm), method(f) // a list contains pointers (iterators) to the all distances related // to a certain sequence. The Vector is accessed via the index of a // sequence in the distance matrix. - - +//ofstream outtemp; +//string temp = "temp"; +//openOutputFile(temp, outtemp); +//cout << lv->size() << endl; seqVec = vector(lv->size()); for (MatData currentCell = dMatrix->begin(); currentCell != dMatrix->end(); currentCell++) { +//outtemp << currentCell->row << '\t' << currentCell->column << '\t' << currentCell->dist << endl; seqVec[currentCell->row].push_back(currentCell); seqVec[currentCell->column].push_back(currentCell); } - +//outtemp.close(); mapWanted = false; //set to true by mgcluster to speed up overlap merge //save so you can modify as it changes in average neighbor cutoff = c; m = MothurOut::getInstance(); + + } + catch(exception& e) { + m->errorOut(e, "Cluster", "Cluster"); + exit(1); + } } /***********************************************************************/ @@ -74,11 +84,16 @@ void Cluster::getRowColCells() { smallRow = smallCell->row; // get its row smallCol = smallCell->column; // get its column smallDist = smallCell->dist; // get the smallest distance - + //cout << "small row = " << smallRow << "small col = " << smallCol << "small dist = " << smallDist << endl; + rowCells = seqVec[smallRow]; // all distances related to the row index colCells = seqVec[smallCol]; // all distances related to the column index nRowCells = rowCells.size(); nColCells = colCells.size(); +//cout << "num rows = " << nRowCells << "num col = " << nColCells << endl; + + //for (int i = 0; i < nColCells; i++) { cout << colCells[i]->row << '\t' << colCells[i]->column << endl; } + //for (int i = 0; i < nRowCells; i++) { cout << rowCells[i]->row << '\t' << rowCells[i]->column << endl; } } catch(exception& e) { m->errorOut(e, "Cluster", "getRowColCells"); @@ -132,7 +147,9 @@ void Cluster::removeCell(const MatData& cell, int vrow, int vcol, bool rmMatrix) seqVec[dcol].erase(seqVec[dcol].begin()+vcol); if (rmMatrix) { + //cout << " removing = " << cell->row << '\t' << cell->column << '\t' << cell->dist << endl; dMatrix->rmCell(cell); + // cout << "done" << endl; } } @@ -224,7 +241,7 @@ void Cluster::update(double& cutOFF){ } } //if not merged it you need it for warning - if ((!merged) && (method == "average")) { + if ((!merged) && (method == "average" || method == "weighted")) { //m->mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine(); if (cutOFF > rowCells[i]->dist) { cutOFF = rowCells[i]->dist; @@ -243,7 +260,7 @@ void Cluster::update(double& cutOFF){ // could be avoided for (int i=nColCells-1;i>=0;i--) { if (foundCol[i] == 0) { - if (method == "average") { + if (method == "average" || method == "weighted") { if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) { //m->mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine(); if (cutOFF > colCells[i]->dist) {