]> git.donarmstrong.com Git - mothur.git/blobdiff - averagelinkage.cpp
added warning about average neighbor merges around cutoff. fixed little bugs.
[mothur.git] / averagelinkage.cpp
index 7a4cb88d366d4f9765d906ce0fc7ea27600a6fdd..db2c51edc5b182b52dcf540456baad7b5782c61e 100644 (file)
@@ -11,8 +11,8 @@
 
 /***********************************************************************/
 
-AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
-       Cluster(rav, lv, dm)
+AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
+       Cluster(rav, lv, dm, c)
 {
        saveRow = -1;
        saveCol = -1;
@@ -37,8 +37,16 @@ bool AverageLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
                        saveRow = smallRow;
                        saveCol = smallCol;
                }
-
+               
+               float oldColCell = colCell->dist;
+               
                colCell->dist = (colBin * colCell->dist + rowBin * rowCell->dist) / totalBin;
+               
+               //warn user if merge with value above cutoff produces a value below cutoff
+               if ((colCell->dist < cutoff) && ((oldColCell > cutoff) || (rowCell->dist > cutoff)) ) {
+                       mothurOut("Warning: merging " + toString(oldColCell) + " with " + toString(rowCell->dist) + ", new value = " + toString(colCell->dist) + ". Results will differ from those if cutoff was used in the read.dist command."); mothurOutEndLine();
+               }
+
                return(true);
        }
        catch(exception& e) {