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 for (int i = 0; i < m->Groups.size(); i++) {
35 if (shared[0]->getGroup() == m->Groups[i]) { group1Index = i; }
36 if (shared[1]->getGroup() == m->Groups[i]) { group2Index = i; }
41 for (int i = 0; i < (numGroups - 1); i++) {
42 for (int l = n; l < numGroups; l++) {
43 if ((group1Index == i) && (group2Index == l)) {
44 pos = numGroupComb; //pos tells you which column in the output file you are in
45 }else if ((group1Index == l) && (group2Index == i)) {
53 if ((estimate->getMultiple() == true) && all) {
55 groupData.resize((numGroupComb*data.size()), 0);
56 //is this the time its called with all values
57 if ((timesCalled % numGroupComb) == 0) {
59 pos = ((groupData.size()-1) * data.size());
61 //fills groupdata with datas info
62 for (int i = 0; i < data.size(); i++) {
63 groupData[pos+i] = data[i];
66 groupData.resize((numGroupComb*data.size()), 0);
67 //fills groupdata with datas info
68 for (int i = 0; i < data.size(); i++) {
69 groupData[pos+i] = data[i];
73 //when you get all your groups info then output
74 if ((timesCalled % numGroupComb) == 0) {
75 output->output(numSeqs, groupData);
79 void init(string s) { output->initFile(s); };
80 void reset() { output->resetFile(); };
81 void close() { output->resetFile(); };
82 void setAll(bool a) { all = a; }
83 bool getAll() { return all; }
86 bool isCalcMultiple() { return estimate->getMultiple(); }
87 bool calcNeedsAll() { return estimate->getNeedsAll(); }
89 if (estimate->getCols() == 3) { return true; }
93 string getName() { return estimate->getName(); }
100 int nSeqs, timesCalled, numGroupComb;
102 vector<double> groupData;
107 /***********************************************************************/