]> git.donarmstrong.com Git - mothur.git/blob - collectdisplay.h
When Pat tried to compile mothur in Ubuntu linux, there were a number of minor proble...
[mothur.git] / collectdisplay.h
1 #ifndef COLLECTDISPLAY_H
2 #define COLLECTDISPLAY_H
3
4 #include "sabundvector.hpp"
5 #include "sharedsabundvector.h"
6 #include "calculator.h"
7 #include "fileoutput.h"
8 #include "display.h"
9 #include <vector>
10
11 using namespace std;
12
13 /***********************************************************************/
14
15 class CollectDisplay : public Display {
16         
17 public:
18         CollectDisplay(Calculator* calc, FileOutput* file) : estimate(calc), output(file) {timesCalled = 0;};
19         ~CollectDisplay()       {       delete estimate; delete output;         }
20         void update(SAbundVector* rank){
21                 nSeqs=rank->getNumSeqs();
22                 data = estimate->getValues(rank);
23                 output->output(nSeqs, data);    
24         };
25         
26         void update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroupComb){
27                 timesCalled++;
28                 data = estimate->getValues(shared1, shared2);  //passes estimators a shared vector from each group to be compared
29                 //fills groupdata with datas info
30                 for (int i = 0; i < data.size(); i++) {
31                         groupData.push_back(data[i]);
32                 }
33                 //when you get all your groups info then output
34                 if ((timesCalled % numGroupComb) == 0) {
35                         output->output(numSeqs, groupData);     
36                         groupData.clear();
37                 }
38         };
39         
40         void init(string s)             {       output->initFile(s);    };
41         void reset()                    {       output->resetFile();    };
42         void close()                    {       output->resetFile();    };
43         
44 private:
45         Calculator* estimate;
46         FileOutput* output;
47         int nSeqs, timesCalled;
48         vector<double> data;
49         vector<double> groupData;
50 };
51
52 /***********************************************************************/
53
54 #endif