X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=averagelinkage.cpp;h=c430c883f66d6006cc9bf01a2a964dd62957688f;hb=ee8403d4eb5760187d62b42a9cf4272de8fc0ec4;hp=26283ff800ca1241be49d4e7eaf18a97d89617d4;hpb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2;p=mothur.git diff --git a/averagelinkage.cpp b/averagelinkage.cpp index 26283ff..c430c88 100644 --- a/averagelinkage.cpp +++ b/averagelinkage.cpp @@ -1,7 +1,7 @@ #ifndef AVERAGE_H #define AVERAGE_H - +//test #include "mothur.h" #include "cluster.hpp" #include "rabundvector.hpp" @@ -11,69 +11,46 @@ /***********************************************************************/ -AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) : -Cluster(rav, lv, dm) -{} +AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) : + Cluster(rav, lv, dm, c, s) +{ + saveRow = -1; + saveCol = -1; +} + /***********************************************************************/ -//THis function clusters based on the average method -void AverageLinkage::update(){ - try{ - getRowColCells(); - - vector found(nColCells, 0); - - int rowBin = rabund->get(smallRow); - int colBin = rabund->get(smallCol); - int totalBin = rowBin + colBin; - - for(int i=1;iget(smallRow); + colBin = rabund->get(smallCol); + totalBin = rowBin + colBin; + saveRow = smallRow; + saveCol = smallCol; + } - if(rowCells[i]->row == smallRow){ - search = rowCells[i]->column; - } - else{ - search = rowCells[i]->row; - } + colCell->dist = (colBin * colCell->dist + rowBin * rowCell->dist) / totalBin; - for(int j=1;jrow == search || colCells[j]->column == search){ - colCells[j]->dist = (colBin * colCells[j]->dist + rowBin * rowCells[i]->dist) / totalBin; - - found[j] = 1; - - if(colCells[j]->vectorMap != NULL){ - *(colCells[j]->vectorMap) = NULL; - colCells[j]->vectorMap = NULL; - } - - break; - } - - } - dMatrix->rmCell(rowCells[i]); - } - - clusterBins(); - clusterNames(); - - for(int i=0;irmCell(colCells[i]); - } - } + return(true); } catch(exception& e) { - errorOut(e, "AverageLinkage", "update"); + m->errorOut(e, "AverageLinkage", "updateDistance"); exit(1); } } /***********************************************************************/ -#endif +/***********************************************************************/ +#endif