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