]> git.donarmstrong.com Git - mothur.git/blobdiff - cluster.cpp
made make.table alias to count.seqs command. added large parameter to count.seqs...
[mothur.git] / cluster.cpp
index 96ca44061436f873ee8b663e248ddcc386c995cb..ac9f4482da12110796c54f15c4137681a3d29038 100644 (file)
@@ -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;
@@ -52,7 +53,7 @@ rabund(rav), list(lv), dMatrix(dm), method(f)
        // sequence in the distance matrix.
 //ofstream outtemp;
 //string temp = "temp";
-//openOutputFile(temp, outtemp);       
+//m->openOutputFile(temp, outtemp);    
 //cout << lv->size() << endl;
        seqVec = vector<MatVec>(lv->size());
        for (MatData currentCell = dMatrix->begin(); currentCell != dMatrix->end(); currentCell++) {
@@ -66,6 +67,12 @@ rabund(rav), list(lv), dMatrix(dm), method(f)
        //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);
+       }
 }
 
 /***********************************************************************/
@@ -198,7 +205,6 @@ void Cluster::clusterNames(){
 void Cluster::update(double& cutOFF){
        try {
                getRowColCells();       
-//cout << "got rowcells" << endl;
 
                vector<int> foundCol(nColCells, 0);
 
@@ -208,6 +214,7 @@ void Cluster::update(double& cutOFF){
                // The vector has to be traversed in reverse order to preserve the index
                // for faster removal in removeCell()
                for (int i=nRowCells-1;i>=0;i--) {
+                       //if you are not the smallCell
                        if (!((rowCells[i]->row == smallRow) && (rowCells[i]->column == smallCol))) {
                                if (rowCells[i]->row == smallRow) {
                                        search = rowCells[i]->column;
@@ -235,7 +242,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;  
@@ -254,7 +261,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) {