]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedordervector.h
speed up rarefaction.shared
[mothur.git] / sharedordervector.h
index f925964e72b7bf7173945b7c04299bbfba1d2fdc..30d655f7347c07fcb9a887ac5330959702e09382 100644 (file)
@@ -2,7 +2,7 @@
 #define SHAREDORDER_H
 /*
  *  sharedorder.h
- *  Dotur
+ *  Mothur
  *
  *  Created by Sarah Westcott on 12/9/08.
  *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
@@ -23,13 +23,20 @@ struct individual {
                string group;
                int bin;
                int abundance;
+               bool operator()(const individual& i1, const individual& i2) {
+               return (i1.abundance > i2.abundance);
+               }
 };
 
-#include <Carbon/Carbon.h>
 #include "sabundvector.hpp"
 #include "rabundvector.hpp"
 #include "sharedrabundvector.h"
 #include "sharedsabundvector.h"
+#include "globaldata.hpp"
+#include "groupmap.h"
+//#include "globaldata.hpp"
+
+class GlobalData;
 
 class SharedOrderVector : public DataVector {
        
@@ -39,18 +46,18 @@ public:
        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();}};
 
        SharedOrderVector(string, vector<individual>);
-//     SharedOrderVector(ifstream&);
+       SharedOrderVector(ifstream&);
        ~SharedOrderVector(){};
        
-       void set(int, int, int, string);        //index, OTU, abundance, group
+       
        individual get(int);
-       void push_back(int, int, string);  //OTU, abundance, group
        void resize(int);
        int size();
        void print(ostream&);
        vector<individual>::iterator begin();
        vector<individual>::iterator end();
-
+       void push_back(int, int, string);  //OTU, abundance, group  MUST CALL UPDATE STATS AFTER PUSHBACK!!!
+       void updateStats();
 
        int getNumBins();
        int getNumSeqs();
@@ -62,15 +69,19 @@ public:
        SharedOrderVector getSharedOrderVector();
        SharedRAbundVector getSharedRAbundVector(string);  //get the sharedRabundvector for a sepecific group
        SharedSAbundVector getSharedSAbundVector(string);       //get the sharedSabundvector for a sepecific group
+       vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
        
 private:
+       GlobalData* globaldata;
+       GroupMap* groupmap;
        vector<individual>  data; 
        map< int, vector<individual> >::iterator it;
        int maxRank;
        int numBins;
        int numSeqs;
        bool needToUpdate;
-       void updateStats();
+       void set(int, int, int, string);        //index, OTU, abundance, group
+       
 };
 
 #endif