]> git.donarmstrong.com Git - mothur.git/blobdiff - averagelinkage.cpp
changes while testing
[mothur.git] / averagelinkage.cpp
index db2c51edc5b182b52dcf540456baad7b5782c61e..8627253777c1b09a1b4b16d1ff2ad4f90468248c 100644 (file)
@@ -1,18 +1,18 @@
 #ifndef AVERAGE_H
 #define AVERAGE_H
 
-
+//test
 #include "mothur.h"
 #include "cluster.hpp"
 #include "rabundvector.hpp"
-#include "sparsematrix.hpp"
+#include "sparsedistancematrix.h"
 
 /* This class implements the average UPGMA, average neighbor clustering algorithm */
 
 /***********************************************************************/
 
-AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-       Cluster(rav, lv, dm, c)
+AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseDistanceMatrix* dm, float c, string s, float a) :
+Cluster(rav, lv, dm, c, s, a)
 {
        saveRow = -1;
        saveCol = -1;
@@ -28,7 +28,7 @@ string AverageLinkage::getTag() {
 
 /***********************************************************************/
 //This function updates the distance based on the average linkage method.
-bool AverageLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
+bool AverageLinkage::updateDistance(PDistCell& colCell, PDistCell& rowCell) {
        try {
                if ((saveRow != smallRow) || (saveCol != smallCol)) {
                        rowBin = rabund->get(smallRow);
@@ -37,20 +37,13 @@ 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();
-               }
-
+               //cout << "colcell.dist = " << colCell.dist << '\t' << smallRow << '\t' << smallCol << '\t' << rowCell.dist << endl;
+               colCell.dist = (colBin * colCell.dist + rowBin * rowCell.dist) / totalBin;
+        
                return(true);
        }
        catch(exception& e) {
-               errorOut(e, "AverageLinkage", "updateDistance");
+               m->errorOut(e, "AverageLinkage", "updateDistance");
                exit(1);
        }
 }