]> git.donarmstrong.com Git - mothur.git/blobdiff - cluster.hpp
added pca command
[mothur.git] / cluster.hpp
index 5f010381f2fbb536a7ac96774523cbf39bc5b98d..a6024e79d45a52274040a53cca4f8b32d9d2e998 100644 (file)
@@ -1,27 +1,33 @@
 #ifndef CLUSTER_H
 #define CLUSTER_H
 
-using namespace std;
 
 #include "mothur.h"
 #include "sparsematrix.hpp"
 
 class RAbundVector;
 class ListVector;
-class SparseMatrix;
 
-typedef list<PCell>::iterator MatData;
+typedef vector<MatData> MatVec;
 
 class Cluster {
        
 public:
        Cluster(RAbundVector*, ListVector*, SparseMatrix*);
-       virtual void update() = 0;
-       
+    virtual void update();                             
+       virtual string getTag() = 0;
+       virtual void setMapWanted(bool m);  
+       virtual map<string, int> 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;
@@ -30,8 +36,12 @@ protected:
        int smallRow;
        int smallCol;
        float smallDist;
-       vector<MatData> rowCells;
-       vector<MatData> colCells;
+       bool mapWanted;
+       map<string, int> seq2Bin;
+       
+       vector<MatVec> seqVec;          // contains vectors of cells related to a certain sequence
+       MatVec rowCells;
+       MatVec colCells;
        ull nRowCells;
        ull nColCells;
 };
@@ -41,7 +51,8 @@ protected:
 class CompleteLinkage : public Cluster {
 public:
        CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*);
-       void update();
+       bool updateDistance(MatData& colCell, MatData& rowCell);
+       string getTag();
        
 private:
                
@@ -52,7 +63,9 @@ private:
 class SingleLinkage : public Cluster {
 public:
        SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*);
-       void update();
+    void update();
+       bool updateDistance(MatData& colCell, MatData& rowCell);
+       string getTag();
        
 private:
                
@@ -63,10 +76,16 @@ private:
 class AverageLinkage : public Cluster {
 public:
        AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*);
-       void update();
+       bool updateDistance(MatData& colCell, MatData& rowCell);
+       string getTag();
        
 private:
-               
+       int saveRow;
+       int saveCol;
+       int rowBin;
+       int colBin;
+       int totalBin;
+
 };
 
 /***********************************************************************/