]> git.donarmstrong.com Git - mothur.git/blob - sharedordervector.h
changes while testing
[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         individual() {  group = ""; bin = 0; abundance = 0; }
28 };
29
30 struct individualFloat {
31                 string group;
32                 int bin;
33                 float abundance;
34                 bool operator()(const individual& i1, const individual& i2) {
35                 return (i1.abundance > i2.abundance);
36                 }
37         individualFloat() { group = ""; bin = 0; abundance = 0.0; }
38 };
39
40
41 #include "sabundvector.hpp"
42 #include "rabundvector.hpp"
43 #include "sharedrabundvector.h"
44 #include "sharedsabundvector.h"
45 #include "groupmap.h"
46
47 class SharedOrderVector : public DataVector {
48         
49 public:
50         SharedOrderVector();
51 //      SharedOrderVector(int ns, int nb=0, int mr=0)   : DataVector(), data(ns, -1), maxRank(0), numBins(0), numSeqs(0) {};
52         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();}};
53
54         SharedOrderVector(string, vector<individual>);
55         SharedOrderVector(ifstream&);
56         ~SharedOrderVector(){};
57         
58         
59         individual get(int);
60         void resize(int);
61         int size();
62         void print(ostream&);
63         vector<individual>::iterator begin();
64         vector<individual>::iterator end();
65         void push_back(int, int, string);  //OTU, abundance, group  MUST CALL UPDATE STATS AFTER PUSHBACK!!!
66         void updateStats();
67         void clear();
68
69         int getNumBins();
70         int getNumSeqs();
71         int getMaxRank();
72                 
73         RAbundVector getRAbundVector();
74         SAbundVector getSAbundVector();
75         OrderVector getOrderVector(map<string,int>*);
76         SharedOrderVector getSharedOrderVector();
77         SharedRAbundVector getSharedRAbundVector(string);  //get the sharedRabundvector for a sepecific group
78         SharedSAbundVector getSharedSAbundVector(string);       //get the sharedSabundvector for a sepecific group
79         vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
80         
81 private:
82         GroupMap* groupmap;
83         vector<individual>  data; 
84         map< int, vector<individual> >::iterator it;
85         int maxRank;
86         int numBins;
87         int numSeqs;
88         bool needToUpdate;
89         void set(int, int, int, string);        //index, OTU, abundance, group
90         
91 };
92
93 #endif
94