]> git.donarmstrong.com Git - mothur.git/blob - cluster.hpp
fixed some bugs and added mgcluster command
[mothur.git] / cluster.hpp
1 #ifndef CLUSTER_H
2 #define CLUSTER_H
3
4
5 #include "mothur.h"
6 #include "sparsematrix.hpp"
7
8 class RAbundVector;
9 class ListVector;
10
11 typedef vector<MatData> MatVec;
12
13 class Cluster {
14         
15 public:
16         Cluster(RAbundVector*, ListVector*, SparseMatrix*);
17     virtual void update();                              
18         virtual string getTag() = 0;
19         virtual void setMapWanted(bool m);  
20         virtual map<string, int> getSeqtoBin()  {  return seq2Bin;      }
21
22 protected:      
23         void getRowColCells();
24     void removeCell(const MatData& cell, int vrow, int vcol, bool rmMatrix=true);
25
26         virtual bool updateDistance(MatData& colCell, MatData& rowCell) = 0;
27
28         virtual void clusterBins();
29         virtual void clusterNames();
30         virtual void updateMap();
31         
32         RAbundVector* rabund;
33         ListVector* list;
34         SparseMatrix* dMatrix;  
35         
36         int smallRow;
37         int smallCol;
38         float smallDist;
39         bool mapWanted;
40         map<string, int> seq2Bin;
41         
42         vector<MatVec> seqVec;          // contains vectors of cells related to a certain sequence
43         MatVec rowCells;
44         MatVec colCells;
45         ull nRowCells;
46         ull nColCells;
47 };
48
49 /***********************************************************************/
50
51 class CompleteLinkage : public Cluster {
52 public:
53         CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*);
54         bool updateDistance(MatData& colCell, MatData& rowCell);
55         string getTag();
56         
57 private:
58                 
59 };
60
61 /***********************************************************************/
62
63 class SingleLinkage : public Cluster {
64 public:
65         SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*);
66     void update();
67         bool updateDistance(MatData& colCell, MatData& rowCell);
68         string getTag();
69         
70 private:
71                 
72 };
73
74 /***********************************************************************/
75
76 class AverageLinkage : public Cluster {
77 public:
78         AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*);
79         bool updateDistance(MatData& colCell, MatData& rowCell);
80         string getTag();
81         
82 private:
83         int saveRow;
84         int saveCol;
85         int rowBin;
86         int colBin;
87         int totalBin;
88
89 };
90
91 /***********************************************************************/
92
93 #endif