1 #ifndef COLLECTDISPLAY_H
2 #define COLLECTDISPLAY_H
4 #include "sabundvector.hpp"
5 #include "sharedsabundvector.h"
6 #include "calculator.h"
7 #include "fileoutput.h"
11 /***********************************************************************/
13 class CollectDisplay : public Display {
16 CollectDisplay(Calculator* calc, FileOutput* file) : estimate(calc), output(file) {timesCalled = 0;};
17 ~CollectDisplay() { delete estimate; delete output; }
20 void update(SAbundVector* rank){
21 nSeqs=rank->getNumSeqs();
22 data = estimate->getValues(rank);
23 output->output(nSeqs, data);
26 void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroups){
28 data = estimate->getValues(shared); //passes estimators a shared vector from each group to be compared
30 //figure out what groups are being compared in getValues
31 //because we randomizes the order we need to put the results in the correct column in the output file
32 int group1Index, group2Index, pos;
34 vector<string> mGroups = m->getGroups();
35 for (int i = 0; i < mGroups.size(); i++) {
36 if (shared[0]->getGroup() == mGroups[i]) { group1Index = i; }
37 if (shared[1]->getGroup() == mGroups[i]) { group2Index = i; }
42 for (int i = 0; i < (numGroups - 1); i++) {
43 for (int l = n; l < numGroups; l++) {
44 if ((group1Index == i) && (group2Index == l)) {
45 pos = numGroupComb; //pos tells you which column in the output file you are in
46 }else if ((group1Index == l) && (group2Index == i)) {
54 if ((estimate->getMultiple() == true) && all) {
56 groupData.resize((numGroupComb*data.size()), 0);
57 //is this the time its called with all values
58 if ((timesCalled % numGroupComb) == 0) {
60 pos = ((groupData.size()-1) * data.size());
62 //fills groupdata with datas info
63 for (int i = 0; i < data.size(); i++) {
64 groupData[pos+i] = data[i];
67 groupData.resize((numGroupComb*data.size()), 0);
68 //fills groupdata with datas info
69 for (int i = 0; i < data.size(); i++) {
70 groupData[pos+i] = data[i];
74 //when you get all your groups info then output
75 if ((timesCalled % numGroupComb) == 0) {
76 output->output(numSeqs, groupData);
80 void init(string s) { output->initFile(s); };
81 void reset() { output->resetFile(); };
82 void close() { output->resetFile(); };
83 void setAll(bool a) { all = a; }
84 bool getAll() { return all; }
87 bool isCalcMultiple() { return estimate->getMultiple(); }
88 bool calcNeedsAll() { return estimate->getNeedsAll(); }
90 if (estimate->getCols() == 3) { return true; }
94 string getName() { return estimate->getName(); }
101 int nSeqs, timesCalled, numGroupComb;
103 vector<double> groupData;
108 /***********************************************************************/