X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cluster.hpp;h=aa517a057400e09cdca593f4db1e2559dca74972;hb=edd8b9d9392a99e0b1527507de3a4ca8fabfc1c6;hp=208ccbfe1ba45ba70d152ba4c5ff12b50182d4dc;hpb=bfbc55964f1977da72c2cea984288a427d370a59;p=mothur.git diff --git a/cluster.hpp b/cluster.hpp index 208ccbf..aa517a0 100644 --- a/cluster.hpp +++ b/cluster.hpp @@ -1,29 +1,34 @@ #ifndef CLUSTER_H #define CLUSTER_H -using namespace std; #include "mothur.h" -#include "utilities.hpp" #include "sparsematrix.hpp" -#include "rabundvector.hpp" +#include "mothurout.h" class RAbundVector; class ListVector; -class SparseMatrix; -typedef list::iterator MatData; +typedef vector MatVec; class Cluster { public: - Cluster(RAbundVector*, ListVector*, SparseMatrix*); - virtual void update() = 0; - + Cluster(RAbundVector*, ListVector*, SparseMatrix*, float, string); + virtual void update(double&); + virtual string getTag() = 0; + virtual void setMapWanted(bool m); + virtual map getSeqtoBin() { return seq2Bin; } + protected: void getRowColCells(); + void removeCell(const MatData& cell, int vrow, int vcol, bool rmMatrix=true); + + virtual bool updateDistance(MatData& colCell, MatData& rowCell) = 0; + virtual void clusterBins(); virtual void clusterNames(); + virtual void updateMap(); RAbundVector* rabund; ListVector* list; @@ -32,18 +37,26 @@ protected: int smallRow; int smallCol; float smallDist; - vector rowCells; - vector colCells; + bool mapWanted; + float cutoff; + map seq2Bin; + string method; + + vector seqVec; // contains vectors of cells related to a certain sequence + MatVec rowCells; + MatVec colCells; ull nRowCells; ull nColCells; + MothurOut* m; }; /***********************************************************************/ class CompleteLinkage : public Cluster { public: - CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*); - void update(); + CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string); + bool updateDistance(MatData& colCell, MatData& rowCell); + string getTag(); private: @@ -53,8 +66,10 @@ private: class SingleLinkage : public Cluster { public: - SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*); - void update(); + SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string); + void update(); + bool updateDistance(MatData& colCell, MatData& rowCell); + string getTag(); private: @@ -64,11 +79,30 @@ private: class AverageLinkage : public Cluster { public: - AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*); - void update(); + AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string); + bool updateDistance(MatData& colCell, MatData& rowCell); + string getTag(); private: - + int saveRow; + int saveCol; + int rowBin; + int colBin; + int totalBin; + +}; + +/***********************************************************************/ + +class WeightedLinkage : public Cluster { +public: + WeightedLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string); + bool updateDistance(MatData& colCell, MatData& rowCell); + string getTag(); + +private: + int saveRow; + int saveCol; }; /***********************************************************************/