]> git.donarmstrong.com Git - mothur.git/blob - sharedordervector.h
d0a714cf98c8d0406fc5ebba751d4fe63d40ac31
[mothur.git] / sharedordervector.h
1 #ifndef SHAREDORDER_H
2 #define SHAREDORDER_H
3 /*
4  *  sharedorder.h
5  *  Mothur
6  *
7  *  Created by Sarah Westcott on 12/9/08.
8  *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
9  *
10  */
11  
12  /* This class is a child to datavector.  It represents OTU information at a certain distance. 
13         It is similiar to an order vector except each member of data knows which group it belongs to.
14         Each member of the internal container "data" represents is an individual which knows the OTU from which it came, 
15         the group it is in and the abundance is equal to the OTU number.  */
16
17
18 #include "datavector.hpp"
19
20 struct individual {
21                 string group;
22                 int bin;
23                 int abundance;
24                 bool operator()(const individual& i1, const individual& i2) {
25                 return (i1.abundance > i2.abundance);
26                 }
27 };
28
29 #include "sabundvector.hpp"
30 #include "rabundvector.hpp"
31 #include "sharedrabundvector.h"
32 #include "sharedsabundvector.h"
33 #include "globaldata.hpp"
34 #include "groupmap.h"
35 //#include "globaldata.hpp"
36
37 class GlobalData;
38
39 class SharedOrderVector : public DataVector {
40         
41 public:
42         SharedOrderVector();
43 //      SharedOrderVector(int ns, int nb=0, int mr=0)   : DataVector(), data(ns, -1), maxRank(0), numBins(0), numSeqs(0) {};
44         SharedOrderVector(const SharedOrderVector& ov)  : DataVector(ov.label), data(ov.data), maxRank(ov.maxRank), numBins(ov.numBins), numSeqs(ov.numSeqs), needToUpdate(ov.needToUpdate) {if(needToUpdate == 1){     updateStats();}};
45
46         SharedOrderVector(string, vector<individual>);
47         SharedOrderVector(ifstream&);
48         ~SharedOrderVector(){};
49         
50         
51         individual get(int);
52         void resize(int);
53         int size();
54         void print(ostream&);
55         vector<individual>::iterator begin();
56         vector<individual>::iterator end();
57         void push_back(int, int, string);  //OTU, abundance, group  MUST CALL UPDATE STATS AFTER PUSHBACK!!!
58         void updateStats();
59
60         int getNumBins();
61         int getNumSeqs();
62         int getMaxRank();
63                 
64         RAbundVector getRAbundVector();
65         SAbundVector getSAbundVector();
66         OrderVector getOrderVector(map<string,int>*);
67         SharedOrderVector getSharedOrderVector();
68         SharedRAbundVector getSharedRAbundVector(string);  //get the sharedRabundvector for a sepecific group
69         SharedSAbundVector getSharedSAbundVector(string);       //get the sharedSabundvector for a sepecific group
70         vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
71         
72 private:
73         GlobalData* globaldata;
74         GroupMap* groupmap;
75         vector<individual>  data; 
76         map< int, vector<individual> >::iterator it;
77         int maxRank;
78         int numBins;
79         int numSeqs;
80         bool needToUpdate;
81         void set(int, int, int, string);        //index, OTU, abundance, group
82         
83 };
84
85 #endif
86