]> git.donarmstrong.com Git - mothur.git/blob - calculator.h
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / calculator.h
1 #ifndef CALCULATOR_H
2 #define CALCULATOR_H
3
4
5 #include "mothur.h"
6 #include "sabundvector.hpp"
7 #include "sharedsabundvector.h"
8 #include "rabundvector.hpp"
9 #include "uvest.h"
10 #include "mothurout.h"
11
12 /* The calculator class is the parent class for all the different estimators implemented in mothur except the tree calculators.
13 It has 2 pure functions EstOutput getValues(SAbundVector*), which works on a single group, and 
14 EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2), which compares 2 groups. */ 
15
16
17 typedef vector<double> EstOutput;
18
19 /***********************************************************************/
20
21 class Calculator {
22
23 public:
24         Calculator(){ m = MothurOut::getInstance(); needsAll = false; }
25         virtual ~Calculator(){};
26         Calculator(string n, int c, bool f) : name(n), cols(c), multiple(f) { m = MothurOut::getInstance(); needsAll = false; };
27         Calculator(string n, int c, bool f, bool a) : name(n), cols(c), multiple(f), needsAll(a) { m = MothurOut::getInstance(); };
28         virtual EstOutput getValues(SAbundVector*) = 0; 
29         virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
30     //optional calc that returns the otus labels of shared otus
31     virtual EstOutput getValues(vector<SharedRAbundVector*> sv , vector<string>&) { data = getValues(sv); return data; }
32         virtual void print(ostream& f)  { f.setf(ios::fixed, ios::floatfield); f.setf(ios::showpoint);
33                                                                           f << data[0]; for(int i=1;i<data.size();i++){ f << '\t' << data[i];   }}
34         virtual string getName()                {       return name;    }
35         virtual int getCols()           {       return cols;    }
36         virtual bool getMultiple()  {   return multiple;   }
37         virtual bool getNeedsAll()  {   return needsAll;   }
38         virtual string getCitation() = 0;
39         void citation() { m->mothurOut(getCitation()); m->mothurOutEndLine(); }
40 protected:
41         MothurOut* m;
42         EstOutput data;
43         string name;
44         int cols;
45         bool multiple;
46         bool needsAll;
47
48 };
49
50 /**************************************************************************************************/
51 /*This Class holds all of the methods that manipulate vectors.
52 These methods are used in the other classes.
53 This class must be included if any of the other classes are to be used. */
54
55 class VecCalc
56 {
57         // The methods seen in the order here is how they are ordered throughout the class.
58         public:
59                 VecCalc(){};
60                 //void printElements(vector<double>); //This prints the values of the vector on one line with a space between each value.
61                 //void printElements(vector<string>); //This prints the values of the vector on one line with a space between each value.
62                 //int findString(vector<string>, string);//This returns the index of the given string in the given <string> vector, if the string does not exist in the vector it returns -1.
63                 //double mean(vector<double>); //This returns the mean value of the vector.
64                 //double stError(vector<double>); //This returns the standard error of the vector.
65                 int sumElements(vector<int>, int);
66                 int sumElements(vector<int>);
67                 double sumElements(vector<double>); //This returns the sum of all the values in the vector.
68                 double sumElements(vector<double>, int); //This returns the sum of all the values in the vector excluding those whose index is before the given index.  
69                 //double findMax(vector<double>); //This returns the maximum value in the vector.
70                 int numNZ(vector<int>); //This returns the number of non-zero values in the vector.
71                 double numNZ(vector<double>); //This returns the number of non-zero values in the vector.
72 };
73
74 /**************************************************************************************************/
75 //This Class stores the table of the confidence limits of the Student-T distribution.
76 class TDTable
77 {
78         public:
79                 double getConfLimit(int,int);
80 };
81 /**************************************************************************************************/
82 #endif
83