]> git.donarmstrong.com Git - mothur.git/commitdiff
added concensus command and updated calcs
authorwestcott <westcott>
Mon, 4 May 2009 13:35:25 +0000 (13:35 +0000)
committerwestcott <westcott>
Mon, 4 May 2009 13:35:25 +0000 (13:35 +0000)
83 files changed:
ace.h
bergerparker.h
bootstrap.h
bootstrapsharedcommand.cpp
bstick.h
calculator.h
chao1.h
collect.cpp
collectdisplay.h
collectorscurvedata.h
commandfactory.cpp
coverage.h
display.h
errorchecking.cpp
fileoutput.cpp
fileoutput.h
geom.h
helpcommand.cpp
jackknife.h
logsd.h
mothur.h
npshannon.h
nseqs.h
qstat.h
raredisplay.cpp
raredisplay.h
rarefact.cpp
rarefactioncurvedata.h
shannon.h
sharedace.cpp
sharedace.h
sharedanderbergs.cpp
sharedanderbergs.h
sharedbraycurtis.cpp
sharedbraycurtis.h
sharedchao1.cpp
sharedchao1.h
sharedjabund.cpp
sharedjabund.h
sharedjclass.cpp
sharedjclass.h
sharedjest.cpp
sharedjest.h
sharedkstest.cpp
sharedkstest.h
sharedkulczynski.cpp
sharedkulczynski.h
sharedkulczynskicody.cpp
sharedkulczynskicody.h
sharedlennon.cpp
sharedlennon.h
sharedmorisitahorn.cpp
sharedmorisitahorn.h
sharednseqs.h
sharedochiai.cpp
sharedochiai.h
sharedordervector.cpp
sharedsobs.cpp
sharedsobs.h
sharedsobscollectsummary.cpp
sharedsobscollectsummary.h
sharedsorabund.cpp
sharedsorabund.h
sharedsorclass.cpp
sharedsorclass.h
sharedsorest.cpp
sharedsorest.h
sharedthetan.cpp
sharedthetan.h
sharedthetayc.cpp
sharedthetayc.h
simpson.h
sobs.h
summarysharedcommand.cpp
summarysharedcommand.h
treegroupscommand.cpp
uvest.cpp
uvest.h
validcommands.cpp
validparameter.cpp
venn.cpp
whittaker.cpp
whittaker.h

diff --git a/ace.h b/ace.h
index c3d156c69729947491a2e5ea86d7a83e5b64ee43..26d93b10014183a3ad94b0d6f991b1e68946494a 100644 (file)
--- a/ace.h
+++ b/ace.h
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class Ace : public Calculator  {
        
 public:
-       Ace(int n) : abund(n), Calculator("ace", 3) {};
+       Ace(int n) : abund(n), Calculator("ace", 3, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 private:
        int abund;
 };
index a0fd2aaf2a3b5996d220e4533c4ec784144f9a4d..7b1dac975608834c615d467364e4f90a0c09d561 100644 (file)
@@ -19,9 +19,9 @@ It is a child of the calculator class.*/
 class BergerParker : public Calculator  {
        
 public:
-       BergerParker() : Calculator("bergerparker", 1) {};
+       BergerParker() : Calculator("bergerparker", 1, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 
 private:
 };
index 7c72ca2222eb47d458cb4780c0006faa37a3135a..e54d9853d1095b62f0f109d85e0276df90bd0fce 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class Bootstrap : public Calculator  {
        
 public:
-       Bootstrap() : Calculator("Bootstrap", 1) {};
+       Bootstrap() : Calculator("Bootstrap", 1, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
        
 };
 
index 9051dd8ea6b11311921e19a1d194bbc7856d3f14..e88972cc19aae9c2e21efa665177925c3e86cf46 100644 (file)
@@ -91,6 +91,7 @@ int BootSharedCommand::execute(){
        try {
                int count = 1;  
                EstOutput data;
+               vector<SharedRAbundVector*> subset;
        
                //if the users entered no valid calculators don't execute command
                if (treeCalculators.size() == 0) { return 0; }
@@ -163,15 +164,19 @@ int BootSharedCommand::execute(){
                                                for (int k = 0; k < lookup.size(); k++) { // pass cdd each set of groups to commpare
                                                        for (int l = k; l < lookup.size(); l++) {
                                                                if (k != l) { //we dont need to similiarity of a groups to itself
+                                                                       subset.clear(); //clear out old pair of sharedrabunds
+                                                                       //add new pair of sharedrabunds
+                                                                       subset.push_back(lookup[k]); subset.push_back(lookup[l]); 
+                                                                       
                                                                        //get estimated similarity between 2 groups
-                                                                       data = treeCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs
+                                                                       data = treeCalculators[i]->getValues(subset); //saves the calculator outputs
                                                                        //save values in similarity matrix
                                                                        simMatrix[k][l] = data[0];
                                                                        simMatrix[l][k] = data[0];
                                                                }
                                                        }
                                                }
-                                       
+                               
                                                //creates tree from similarity matrix and write out file
                                                createTree(out[i]);
                                        }
@@ -219,8 +224,8 @@ void BootSharedCommand::createTree(ostream* out){
                //do merges and create tree structure by setting parents and children
                //there are numGroups - 1 merges to do
                for (int i = 0; i < (numGroups - 1); i++) {
-                       
-                       float largest = 0.0;
+               
+                       float largest = -1.0;
                        int row, column;
                        //find largest value in sims matrix by searching lower triangle
                        for (int j = 1; j < simMatrix.size(); j++) {
@@ -232,7 +237,7 @@ void BootSharedCommand::createTree(ostream* out){
                        //set non-leaf node info and update leaves to know their parents
                        //non-leaf
                        t->tree[numGroups + i].setChildren(index[row], index[column]);
-                       
+               
                        //parents
                        t->tree[index[row]].setParent(numGroups + i);
                        t->tree[index[column]].setParent(numGroups + i);
@@ -243,36 +248,36 @@ void BootSharedCommand::createTree(ostream* out){
                        //branchlengths
                        t->tree[index[row]].setBranchLength(blength - t->tree[index[row]].getLengthToLeaves());
                        t->tree[index[column]].setBranchLength(blength - t->tree[index[column]].getLengthToLeaves());
-                       
+               
                        //set your length to leaves to your childs length plus branchlength
                        t->tree[numGroups + i].setLengthToLeaves(t->tree[index[row]].getLengthToLeaves() + t->tree[index[row]].getBranchLength());
                        
-                       
+               
                        //update index 
                        index[row] = numGroups+i;
                        index[column] = numGroups+i;
                        
                        //zero out highest value that caused the merge.
-                       simMatrix[row][column] = 0.0;
-                       simMatrix[column][row] = 0.0;
-                       
+                       simMatrix[row][column] = -1.0;
+                       simMatrix[column][row] = -1.0;
+               
                        //merge values in simsMatrix
                        for (int n = 0; n < simMatrix.size(); n++)      {
                                //row becomes merge of 2 groups
                                simMatrix[row][n] = (simMatrix[row][n] + simMatrix[column][n]) / 2;
                                simMatrix[n][row] = simMatrix[row][n];
                                //delete column
-                               simMatrix[column][n] = 0.0;
-                               simMatrix[n][column] = 0.0;
+                               simMatrix[column][n] = -1.0;
+                               simMatrix[n][column] = -1.0;
                        }
                }
-       
+
                //assemble tree
                t->assembleTree();
-               
+       
                //print newick file
                t->print(*out);
-               
+       
                //delete tree
                delete t;
        
index f4693b7974ea60dace28bcb088b64d9c09d6629d..476b588d64f7223cfe2222ea15f2724d6f3ecdaf 100644 (file)
--- a/bstick.h
+++ b/bstick.h
@@ -18,9 +18,9 @@ It is a child of the calculator class.*/
 class BStick : public Calculator  {
        
 public:
-       BStick() : Calculator("bstick", 3) {};
+       BStick() : Calculator("bstick", 3, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 
 private:
        double invSum(int, double);
index 4cc32806ff7536908c5f75a233e255dd321dd72a..127c835e13318dbc8c0e853d510add1ddbc9c8a7 100644 (file)
@@ -23,17 +23,19 @@ class Calculator {
 
 public:
        Calculator(){};
-       Calculator(string n, int c) : name(n), cols(c) {};
+       Calculator(string n, int c, bool m) : name(n), cols(c), multiple(m) {};
        virtual EstOutput getValues(SAbundVector*) = 0; 
-       virtual EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) = 0;
+       virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
        virtual void print(ostream& f)  { f.setf(ios::fixed, ios::floatfield); f.setf(ios::showpoint);
                                                                          f << data[0]; for(int i=1;i<data.size();i++){ f << '\t' << data[i];   }}
        virtual string getName()                {       return name;    }
        virtual int getCols()           {       return cols;    }
+       virtual bool getMultiple()  {   return multiple;   }
 protected:
        EstOutput data;
        string name;
        int cols;
+       bool multiple;
 
 };
 
diff --git a/chao1.h b/chao1.h
index 548e1a7b3694fe992bc5490999239b3b03cb2975..27b7827f8db1d55225935ab13605da2f339f83cf 100644 (file)
--- a/chao1.h
+++ b/chao1.h
@@ -19,9 +19,9 @@ It is a child of the calculator class. */
 class Chao1 : public Calculator  {
        
 public: 
-       Chao1() : Calculator("Chao", 3) {};
+       Chao1() : Calculator("Chao", 3, false) {};
        EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 };
 
 
index 8043dc14f90f0828d2138f34b10424c878c58545..d109ca0540c01a78ca7e08c5c0e7bf6dfad85d90 100644 (file)
@@ -63,6 +63,7 @@ void Collect::getSharedCurve(int increment = 1){
 try {
                 globaldata = GlobalData::getInstance();
                 vector<SharedRAbundVector*> lookup; 
+                               vector<SharedRAbundVector*> subset;
 
                 //create and initialize vector of sharedvectors, one for each group
                 for (int i = 0; i < globaldata->Groups.size(); i++) { 
@@ -78,14 +79,18 @@ try {
                 //initialize labels for output
                 //makes  'uniqueAB         uniqueAC  uniqueBC' if your groups are A, B, C
                 getGroupComb();
-                groupLabel = "";
+                groupLabel = ""; 
                 for (int s = 0; s < groupComb.size(); s++) {
                         groupLabel = groupLabel + label + groupComb[s] + "\t";
                 }
-
+                               
+                               //for multi displays
+                               string groupLabelAll = groupLabel + label + "all\t";
+                               
                 for(int i=0;i<displays.size();i++){
                         ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
-                        displays[i]->init(groupLabel);                  
+                                               if (displays[i]->isCalcMultiple() == true)  {   displays[i]->init(groupLabelAll); }
+                                               else {  displays[i]->init(groupLabel);  }           
                 }
                 
                 //sample all the members
@@ -106,16 +111,19 @@ try {
        
                         //calculate at 0 and the given increment
                         if((i == 0) || (i+1) % increment == 0){
-                                //randomize group order
-                                if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); }
-                                //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
+                                                               //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
                                 int n = 1;
                                 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                         for (int l = n; l < lookup.size(); l++) {
-                                                ccd->updateSharedData(lookup[k], lookup[l], i+1, globaldata->Groups.size());
+                                                                                               subset.clear(); //clear out old pair of sharedrabunds
+                                                                                               //add new pair of sharedrabund vectors
+                                                                                               subset.push_back(lookup[k]); subset.push_back(lookup[l]);
+                                                ccd->updateSharedData(subset, i+1, globaldata->Groups.size());
                                         }
                                         n++;
                                 }
+                                                               //if this is a calculator that can do multiples then do them
+                                                               ccd->updateSharedData(lookup, i+1, globaldata->Groups.size()); 
                         }
                         totalNumSeq = i+1;
                 }
@@ -126,10 +134,15 @@ try {
                         int n = 1;
                         for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                 for (int l = n; l < lookup.size(); l++) {
-                                        ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, globaldata->Groups.size());
+                                                                               subset.clear(); //clear out old pair of sharedrabunds
+                                                                               //add new pair of sharedrabund vectors
+                                                                               subset.push_back(lookup[k]); subset.push_back(lookup[l]);
+                                                                               ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size());
                                 }
                                 n++;
                         }
+                                               //if this is a calculator that can do multiples then do them
+                                               ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size()); 
                 }
                 
                 //resets output files
index af97c756d6a813959cabf5ce8f13f9e70f206806..7e40ad7359c7553a033ee03645ad6eb2421012ae 100644 (file)
@@ -23,15 +23,15 @@ public:
                output->output(nSeqs, data);    
        };
        
-       void update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroups){
+       void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroups){
                timesCalled++;
-               data = estimate->getValues(shared1, shared2);  //passes estimators a shared vector from each group to be compared
+               data = estimate->getValues(shared);  //passes estimators a shared vector from each group to be compared
                
                //figure out what groups are being compared in getValues
                //because the jumble parameter randomizes the order we need to put the results in the correct column in the output file
                int group1Index, group2Index, pos;
-               group1Index = shared1->getGroupIndex();
-               group2Index = shared2->getGroupIndex();
+               group1Index = shared[0]->getGroupIndex();
+               group2Index = shared[1]->getGroupIndex();
                
                numGroupComb = 0;
                int n = 1;
@@ -46,12 +46,25 @@ public:
                        }
                        n++;
                }
-
-               groupData.resize((numGroupComb*data.size()), 0);
                
-               //fills groupdata with datas info
-               for (int i = 0; i < data.size(); i++) {
-                       groupData[pos+i] = data[i];
+               if (estimate->getMultiple() == true) { 
+                       numGroupComb++; 
+                       groupData.resize((numGroupComb*data.size()), 0);
+                       //is this the time its called with all values
+                       if  ((timesCalled % numGroupComb) == 0) { 
+                               //last spot
+                               pos = ((groupData.size()-1) * data.size());
+                       }
+                       //fills groupdata with datas info
+                       for (int i = 0; i < data.size(); i++) {
+                               groupData[pos+i] = data[i];
+                       }
+               }else {
+                       groupData.resize((numGroupComb*data.size()), 0);
+                       //fills groupdata with datas info
+                       for (int i = 0; i < data.size(); i++) {
+                               groupData[pos+i] = data[i];
+                       }
                }
                
                //when you get all your groups info then output
@@ -63,6 +76,7 @@ public:
        void init(string s)             {       output->initFile(s);    };
        void reset()                    {       output->resetFile();    };
        void close()                    {       output->resetFile();    };
+       bool isCalcMultiple() { return estimate->getMultiple(); }
        
 private:
        Calculator* estimate;
index af81c39269b46aa69cf4083f22807e0815fdb449..480bc362bcea7bf2c39a0f4edf75492b4a86b846 100644 (file)
@@ -40,23 +40,25 @@ private:
 class SharedCollectorsCurveData : public Observable {
        
 public:
-       SharedCollectorsCurveData() : shared1(0), shared2(0) {};
+       SharedCollectorsCurveData() { }; //: shared1(0), shared2(0)
        
        void registerDisplay(Display* o)                {       displays.insert(o);                             };
        void removeDisplay(Display* o)                  {       displays.erase(o);      delete o;       };
-       void SharedDataChanged()                                        {       notifyDisplays();                               };
-       void updateSharedData(SharedRAbundVector* rv, SharedRAbundVector* rv2, int numSeqs, int numGroupComb)   {       shared1 = rv; shared2 = rv2; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged();       };
-
+       void SharedDataChanged()                                {       notifyDisplays();                               };
+       void updateSharedData(vector<SharedRAbundVector*> s, int numSeqs, int numGroupComb)     {       shared = s; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged();        };
+       
        void notifyDisplays(){  
                for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-                       (*pos)->update(shared1, shared2, NumSeqs, NumGroupComb);
+                       if ( ((*pos)->isCalcMultiple() == true) || ( ((*pos)->isCalcMultiple() == false) && (shared.size() == 2) ) ) {
+                               (*pos)->update(shared, NumSeqs, NumGroupComb);
+                       }
                }       
        };
        
 private:
        set<Display*> displays;
-       SharedRAbundVector* shared1;
-       SharedRAbundVector* shared2;
+       vector<Display*> multiDisplays;
+       vector<SharedRAbundVector*> shared;
        int NumSeqs, NumGroupComb;
 };
 
index ff156139ea3f3c1d67791d440113177fc261a700..1f6f828faa16e6a1473431057ae02962efe06921 100644 (file)
@@ -37,6 +37,7 @@
 #include "getoturepcommand.h"
 #include "treegroupscommand.h"
 #include "bootstrapsharedcommand.h"
+#include "concensuscommand.h"
 
 
 /***********************************************************/
@@ -86,6 +87,7 @@ Command* CommandFactory::getCommand(string commandName){
                else if(commandName == "get.oturep")                    {   command = new GetOTURepCommand();                   }
                else if(commandName == "tree.shared")                   {   command = new TreeGroupCommand();                   }
                else if(commandName == "bootstrap.shared")              {   command = new BootSharedCommand();                  }
+               else if(commandName == "concensus")                             {   command = new ConcensusCommand();                   }
                else                                                                                    {       command = new NoCommand();                                      }
 
                return command;
index c17f8e7cbdd7d38465fba23ceff41ad98f7ac6a4..7b89c1e6f07d420a0e8a1737fc21154d44a411ce 100644 (file)
@@ -20,9 +20,9 @@
 class Coverage : public Calculator  {
        
 public: 
-       Coverage() : Calculator("coverage", 1) {};
+       Coverage() : Calculator("coverage", 1, false) {};
        EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 };
 
 
index 17867c8197575725d9361daf514c5431039f7429..c4301baefec3d8590ef405fe47f1f08e0c9b3db8 100644 (file)
--- a/display.h
+++ b/display.h
@@ -15,10 +15,11 @@ class Display {
        
 public:
        virtual void update(SAbundVector* rank) = 0;
-       virtual void update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroupComb) = 0;
+       virtual void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroupComb) = 0;
        virtual void init(string) = 0;
        virtual void reset() = 0;
        virtual void close() = 0;
+       virtual bool isCalcMultiple() = 0;
        
 private:
 
index aa223a20379d1fd590908fbb5aa92c7a38cbf03b..16933549c7539e73460ef7f8a84dd068f60d98be 100644 (file)
@@ -196,9 +196,9 @@ bool ErrorCheck::checkInput(string input) {
                        }
                }
                
-               if ((commandName == "unifrac.weighted") || (commandName == "unifrac.unweighted")) {
+               if ((commandName == "unifrac.weighted") || (commandName == "unifrac.unweighted") || (commandName == "concensus")) {
                        if (globaldata->gTree.size() == 0) {//no trees were read
-                               cout << "You must execute the read.tree command, before you may execute the unifrac.weighted or unifrac.unweighted command." << endl; return false;  }
+                               cout << "You must execute the read.tree command, before you may execute the unifrac.weighted, unifrac.unweighted or concensus command." << endl; return false;  }
                }
                
                //check for valid method
index 9c1f9c0f0c61fe3b27d84f699482d8708ad1e660..74b53352a8a0d4d177635a9b4d52370030b06f45 100644 (file)
@@ -90,7 +90,7 @@ void ThreeColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) {  cout << "Unable to rename necessary files." << endl;  cout << outName << "  g   " << inName << endl;}
+               if ((renameOk != 0)) {  cout << "Unable to rename necessary files." << endl; }
 
        }
        catch(exception& e) {
index 3b73b148d88c7052421d48358c8ccdf0b39035ed..d7c4726e3f3d2b13786ebcf8bf6afa792b39fe52 100644 (file)
@@ -32,7 +32,7 @@ protected:
 class ThreeColumnFile : public FileOutput {
        
 public:
-       ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { };
+       ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp") { };
        ~ThreeColumnFile();
        void initFile(string);
        void output(int, vector<double>);
@@ -56,7 +56,7 @@ class OneColumnFile : public FileOutput {
        
        
 public:
-       OneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) {};
+       OneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp") {};
        ~OneColumnFile();
        void output(int, vector<double>);
        void initFile(string);
@@ -80,7 +80,7 @@ class SharedOneColumnFile : public FileOutput {
        
        
 public:
-       SharedOneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) {};
+       SharedOneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp") {};
        ~SharedOneColumnFile();
        void output(int, vector<double>);
        void initFile(string);
@@ -105,7 +105,7 @@ private:
 class SharedThreeColumnFile : public FileOutput {
        
 public:
-       SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(getPathName(n) + ".temp." + getSimpleName(n)) {  };
+       SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(getPathName(n) + ".temp") {      };
        ~SharedThreeColumnFile();
        void initFile(string);
        void output(int, vector<double>);
@@ -125,11 +125,11 @@ private:
 };
 
 /***********************************************************************/
-
+//used by parsimony, unifrac.weighted and unifrac.unweighted
 class ColumnFile : public FileOutput {
        
 public:
-       ColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { globaldata = GlobalData::getInstance(); };
+       ColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp") { globaldata = GlobalData::getInstance(); };
        ~ColumnFile();
        
        //to make compatible with parent class
diff --git a/geom.h b/geom.h
index f88cb4acb33d2cf4027062f309329f3bc9f9aaf6..be60de39ed6d6f6e116e886f4a7aa608739e63db 100644 (file)
--- a/geom.h
+++ b/geom.h
@@ -19,9 +19,11 @@ It is a child of the calculator class. */
 class Geom : public Calculator  {
        
 public:
-       Geom() : Calculator("geometric", 3) {};
+
+       Geom() : Calculator("geometric", 3, false) {};
+
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 
 private:
        double kEq(double, double);
index ac013303de6e837847416e343295ee613593f12e..8060d5fc132a7920bd800ecb6dbc3e6c514312b3 100644 (file)
@@ -83,11 +83,11 @@ int HelpCommand::execute(){
                cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "collect.shared") {
                cout << "The collect.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The collect.shared command parameters are label, line, freq, jumble, calc and groups.  No parameters are required, but you may not use " << "\n";
+               cout << "The collect.shared command parameters are label, line, freq, calc and groups.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The collect.shared command should be in the following format: " << "\n";
-               cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, jumble=yourJumble, calc=yourEstimators, groups=yourGroups)." << "\n";
-               cout << "Example collect.shared(label=unique-.01-.03, line=0-5-10, freq=10, jumble=1, groups=B-C, calc=sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
-               cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan." << "\n";
+               cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, calc=yourEstimators, groups=yourGroups)." << "\n";
+               cout << "Example collect.shared(label=unique-.01-.03, line=0-5-10, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
+               cout << "The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan." << "\n";
                cout << "The default value for groups is all the groups in your groupfile." << "\n";
                validCalcs->printCalc("shared", cout);
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
@@ -147,12 +147,12 @@ int HelpCommand::execute(){
                cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "summary.shared") { 
                cout << "The summary.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The summary.shared command parameters are label, line, jumble and calc.  No parameters are required, but you may not use " << "\n";
+               cout << "The summary.shared command parameters are label, line and calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The summary.shared command should be in the following format: " << "\n";
-               cout << "summary.shared(label=yourLabel, line=yourLines, jumble=yourJumble, calc=yourEstimators, groups=yourGroups)." << "\n";
-               cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, groups=B-C, calc=sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
+               cout << "summary.shared(label=yourLabel, line=yourLines, calc=yourEstimators, groups=yourGroups)." << "\n";
+               cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
                validCalcs->printCalc("sharedsummary", cout);
-               cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and calc is sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan" << "\n";
+               cout << "The default value for calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan" << "\n";
                cout << "The default value for groups is all the groups in your groupfile." << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
                cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups." << "\n";
@@ -250,6 +250,15 @@ int HelpCommand::execute(){
                validCalcs->printCalc("boot", cout);
                cout << "The bootstrap.shared command outputs a .tre file for each calculator you specify at each distance you choose containing iters number of trees." << "\n";
                cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+       }else if (globaldata->helpRequest == "concensus") { 
+               cout << "The concensus command can only be executed after a successful read.tree command." << "\n";
+               cout << "The concensus command has no parameters." << "\n";
+               cout << "The concensus command should be in the following format: concensus()." << "\n";
+               cout << "The concensus command output two files: .concensus.tre and .concensuspairs." << "\n";
+               cout << "The .concensus.tre file contains the concensus tree of the trees in your input file." << "\n";
+               cout << "The branch lengths are the percentage of trees in your input file that had the given pair." << "\n";
+               cout << "The .concensuspairs file contains a list of the internal nodes in your tree.  For each node, the pair that was used in the concensus tree " << "\n";
+               cout << "is reported with its percentage, as well as the other pairs that were seen for that node but not used and their percentages." << "\n" << "\n";
        }else if (globaldata->helpRequest == "bin.seqs") { 
                cout << "The bin.seqs command can only be executed after a successful read.otu command of a list file." << "\n";
                cout << "The bin.seqs command parameters are fasta, name, line and label.  The fasta parameter is required, and you may not use line and label at the same time." << "\n";
index ec920e0a184231c77dda1cc4ca1626fe42a07f8d..70f1dcad196ad15113873a059483ab18557de585 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class Jackknife : public Calculator  {
        
 public:
-       Jackknife() : Calculator("Jackknife", 3) {      getAMatrix(); };
+       Jackknife() : Calculator("Jackknife", 3, false) {       getAMatrix(); };
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 
 private:
        static const int maxOrder = 30;
diff --git a/logsd.h b/logsd.h
index 7bb12c3ce8791461bc8e904fc04d688ffb5856b6..70d584dec9e19c4cc5362e4e9555c103e74e1231 100644 (file)
--- a/logsd.h
+++ b/logsd.h
@@ -19,9 +19,10 @@ It is a child of the calculator class.*/
 class LogSD : public Calculator  {
        
 public:
-       LogSD() : Calculator("logseries", 3) {};
+
+       LogSD() : Calculator("logseries", 3, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) { return data; };
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 
 private:
        double logS(double);
index 36d7b28ebf45dd3f4bf1d0555c74f4e99c841fe9..8ad1645a57a5345a7f48ca8236d83963d8700afc 100644 (file)
--- a/mothur.h
+++ b/mothur.h
@@ -42,7 +42,15 @@ using namespace std;
 
 typedef unsigned long long ull;
 
-
+struct IntNode {
+       int lvalue;
+       int rvalue;
+       int lcoef;
+       int rcoef;
+       IntNode* left;
+       IntNode* right;
+};
+       
 /***********************************************************************/
 
 // snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2
@@ -95,7 +103,6 @@ string toHex(const T&x){
 
     return output.str();
 }
-
 //**********************************************************************************************************************
 
 template<typename T>
@@ -203,6 +210,17 @@ inline string getSimpleName(string longName){
 
        return simpleName;
 }
+/***********************************************************************/
+
+inline int factorial(int num){
+       int total = 1;
+       
+       for (int i = 1; i <= num; i++) {
+               total *= i;
+       }
+       
+       return total;
+}
 
 /***********************************************************************/
 
index 9272409a995b3ddff581d796002b44dbdfeaf6ae..dc137edf08cc8777c80a349e0cc39ff9d1b7f917 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class NPShannon : public Calculator  {
        
 public:
-       NPShannon() : Calculator("NPShannon", 1) {};
+       NPShannon() : Calculator("NPShannon", 1, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 private:
        
 };
diff --git a/nseqs.h b/nseqs.h
index 0a7b0c355dec5eaf4cddc1206bf9b0339d2781e2..1382add6e58b78ba88c6459168df9d554d45e71d 100644 (file)
--- a/nseqs.h
+++ b/nseqs.h
 class NSeqs : public Calculator {
 
 public:
-       NSeqs() : Calculator("NSeqs", 1) {};
+       NSeqs() : Calculator("NSeqs", 1, false) {};
        EstOutput getValues(SAbundVector* rank){
                data.resize(1,0);
                data[0] = (double)rank->getNumSeqs();
                return data;
        }
-       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 };
 
 /***********************************************************************/
diff --git a/qstat.h b/qstat.h
index b0c985a88a45d7ad88a6a868db0aee7097998f2c..5bc6d9e5b92f8dfdd1cce82abd08615c651ca6b1 100644 (file)
--- a/qstat.h
+++ b/qstat.h
@@ -18,9 +18,10 @@ It is a child of the calculator class.*/
 class QStat : public Calculator  {
        
 public:
-       QStat() : Calculator("qstat", 1) {};
+       QStat() : Calculator("qstat", 1, false) {};
+
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 
 private:
        RAbundVector rdata;
index 812626604483ca0ab0d5978e2ea8c9542d394fc6..6843ebe61b1d6c2bd650a296d286c9a3ec92b0af 100644 (file)
@@ -68,9 +68,9 @@ void RareDisplay::update(SAbundVector* rank){
 };
 
 /***********************************************************************/
-void RareDisplay::update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroupComb) {
+void RareDisplay::update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroupComb) {
        try {
-               vector<double> data = estimate->getValues(shared1, shared2); 
+               vector<double> data = estimate->getValues(shared); 
                double newNSeqs = data[0];
                
                if(nIters != 1){
index ff7de73f24146a3b9d8401712c330adabcd8288d..b7711d2952861086b0efc27e049159073db4ac31 100644 (file)
@@ -15,13 +15,14 @@ class RareDisplay : public Display {
        
 public:
        RareDisplay(Calculator* calc, FileOutput* file) : estimate(calc), output(file), nIters(1),
-                                                       tempInName(getPathName(output->getFileName()) + ".tempin."+ getSimpleName(output->getFileName())), tempOutName(getPathName(output->getFileName()) + ".tempout."+ getSimpleName(output->getFileName())) {};
+                                                       tempInName(getPathName(output->getFileName()) + ".tempin"), tempOutName(getPathName(output->getFileName()) + ".tempout") {};
        ~RareDisplay()                                  {       delete estimate; delete output;         };
        void init(string);
        void reset();
        void update(SAbundVector*);
-       void update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroupComb);
+       void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroupComb);
        void close();
+       bool isCalcMultiple() { return estimate->getMultiple(); }
        
 private:
        Calculator* estimate;
index 2f5f5067a388f1c9c6026a32cff81f003fec1106..d7df01ea57d50d256ee9962939a527837d3beed1 100644 (file)
@@ -114,10 +114,15 @@ try {
                        
                        //randomize the groups
                        random_shuffle(lookup.begin(), lookup.end());
-               
+                       
+                       vector<SharedRAbundVector*> subset;
                        //send each group one at a time
                        for (int k = 0; k < lookup.size(); k++) { 
-                               rcd->updateSharedData(lookup[0], lookup[k], k+1, numGroupComb);
+                               subset.clear(); //clears out old pair of sharedrabunds
+                               //add in new pair of sharedrabunds
+                               subset.push_back(lookup[0]); subset.push_back(lookup[k]);
+                               
+                               rcd->updateSharedData(subset, k+1, numGroupComb);
                                mergeVectors(lookup[0], lookup[k]);
                        }
 
index 9d97b809f683125ccc78740197f303f94c3fcf5c..fad613bc9127161a41db59ae623977c503963655 100644 (file)
@@ -38,23 +38,22 @@ private:
 class SharedRarefactionCurveData : public Observable {
        
 public:
-       SharedRarefactionCurveData() : shared1(0), shared2(0) {};
+       SharedRarefactionCurveData() {}; //: shared1(0), shared2(0) 
        
        void registerDisplay(Display* o)        {       displays.insert(o);                             };
        void removeDisplay(Display* o)          {       displays.erase(o);      delete o;       };
        void SharedDataChanged()                        {       notifyDisplays();                               };
-       void updateSharedData(SharedRAbundVector* rv, SharedRAbundVector* rv2, int numSeqs, int numGroupComb)   {       shared1 = rv; shared2 = rv2; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged(); };
+       void updateSharedData(vector<SharedRAbundVector*> r, int numSeqs, int numGroupComb)     {       shared = r; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged(); };
 
        void notifyDisplays(){  
                for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-                               (*pos)->update(shared1, shared2, NumSeqs, NumGroupComb);
+                               (*pos)->update(shared, NumSeqs, NumGroupComb);
                }       
        };
        
 private:
        set<Display*> displays;
-       SharedRAbundVector* shared1;
-       SharedRAbundVector* shared2;
+       vector<SharedRAbundVector*> shared;
        int NumSeqs, NumGroupComb;
        
 };
index e594c09d496c5e1e3b8cee3fd636a99d010246e3..1930239507b5506a7f05f9fe24a3bca4309eb346 100644 (file)
--- a/shannon.h
+++ b/shannon.h
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class Shannon : public Calculator  {
        
 public:
-       Shannon() : Calculator("Shannon", 3) {};
+       Shannon() : Calculator("Shannon", 3, false) {};
        EstOutput getValues(SAbundVector* rank);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 private:
        
 };
index 87305965d135f8ac6b88c922c100dc0ddac91118..34ad28bec83ffd580e29aca410a3c2afb0a554d9 100644 (file)
 
 /***********************************************************************/
 
-EstOutput SharedAce::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput SharedAce::getValues(vector<SharedRAbundVector*> shared) {
        try {
                data.resize(1,0);
                string label;
-               label = shared1->getLabel();
+               label = shared[0]->getLabel();
 
                int fARare, fBRare, S12Rare, S12Abund, S12, f11, tempA, tempB, t10, t01, t11, t21, t12, t22, C12Numerator;
                fARare = 0; fBRare = 0; S12Rare = 0; S12Abund = 0; S12 = 0; f11 = 0; t10 = 0; t01 = 0; t11= 0; t21= 0; t12= 0; t22= 0; C12Numerator = 0;
        
-               float SharedAce, C12, part1, part2, part3, part4, part5, Gamma1, Gamma2, Gamma3;
+               float Sharedace, C12, part1, part2, part3, part4, part5, Gamma1, Gamma2, Gamma3;
        
                /*fARare = number of OTUs with one individual found in A and less than or equal to 10 in B. 
                fBRare = number of OTUs with one individual found in B and less than or equal to 10 in A. 
@@ -32,10 +32,10 @@ EstOutput SharedAce::getValues(SharedRAbundVector* shared1, SharedRAbundVector*
                S12 = number of shared OTUs in A and B
                This estimator was changed to reflect Caldwell's changes, eliminating the nrare / nrare - 1 */
 
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        if ((tempA != 0) && (tempB != 0)) {//they are shared
                                S12++;
                                //do both A and B have one
@@ -94,8 +94,8 @@ EstOutput SharedAce::getValues(SharedRAbundVector* shared1, SharedRAbundVector*
                part4 = fBRare * Gamma2;
                part5 = f11 * Gamma3;
 
-               SharedAce = S12Abund + part1 + (part2 * (part3 + part4 + part5));
-               data[0] = SharedAce;
+               Sharedace = S12Abund + part1 + (part2 * (part3 + part4 + part5));
+               data[0] = Sharedace;
        
                return data;
        }
index f30e196b7fbd7b690d73d3e68f11299c801c7a8f..d8f69e16c74742b4d248ddcd60c8f3f440e916de 100644 (file)
@@ -19,9 +19,9 @@ It is a child of the calculator class. */
 class SharedAce : public Calculator  {
        
 public:
-       SharedAce(int n=10) : abund(n),  Calculator("sharedace", 3) {};
+       SharedAce(int n=10) : abund(n),  Calculator("sharedace", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        int abund;
 };
index 08ca8fd9cf5ebc46716fe854f7415b9bb73f5e20..0a113abebd30c758eeda592bab4e86981373a9a6 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput Anderberg::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput Anderberg::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
@@ -21,10 +21,10 @@ EstOutput Anderberg::getValues(SharedRAbundVector* shared1, SharedRAbundVector*
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        if (tempA != 0) { S1++; }
                        if (tempB != 0) { S2++; } 
index 1c8d9ce64a80c9004efbe647d1e2799d5e640861..f17e5fa8e3767a115d6b9393f258f696bf9ff793 100644 (file)
@@ -16,9 +16,9 @@
 class Anderberg : public Calculator  {
        
        public:
-               Anderberg() :  Calculator("Anderberg", 1) {};
+               Anderberg() :  Calculator("Anderberg", 1, false) {};
                EstOutput getValues(SAbundVector*) {return data;};
-               EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+               EstOutput getValues(vector<SharedRAbundVector*>);
        private:
 
 };
index d1b401eb78038aaa8d462678fe7bcbc3d2b13903..9a63cdf9c0a3cbf37fd2ef179ef5bd8ff3229bc7 100644 (file)
@@ -10,8 +10,8 @@
 #include "sharedbraycurtis.h"
 
 /***********************************************************************/
-
-EstOutput BrayCurtis::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+//This is used by SharedJAbund and SharedSorAbund
+EstOutput BrayCurtis::getValues(vector<SharedRAbundVector*> shared) {
        try {   
                data.resize(1,0);
                
@@ -24,10 +24,10 @@ EstOutput BrayCurtis::getValues(SharedRAbundVector* shared1, SharedRAbundVector*
                sumSharedAB = the sum of the minimum otus int all shared otus in AB.
                */
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        sumSharedA += tempA;
                        sumSharedB += tempB;
index bbd09f598270e789829b9bff61fe50a2da53f253..446b3eb66ae07c489b7557024cfd5117e8e40fa4 100644 (file)
@@ -15,9 +15,9 @@
 class BrayCurtis : public Calculator  {
        
 public:
-       BrayCurtis() :  Calculator("BrayCurtis", 1) {};
+       BrayCurtis() :  Calculator("BrayCurtis", 1, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 02e241180d2d4855309a8f8aa01a279963b506e5..0df0eabf8c2829ce6f6184276871687da66d4120 100644 (file)
 #include "sharedchao1.h"
 
 /***********************************************************************/
-EstOutput SharedChao1::getValues(SharedRAbundVector* sharedA, SharedRAbundVector* sharedB){
+EstOutput SharedChao1::getValues(vector<SharedRAbundVector*> shared){
        try {
                data.resize(1,0);
                
-               int f11, f1A, f2A, f1B, f2B, S12, tempA, tempB;
-               f11 = 0; f1A = 0; f2A = 0; f1B = 0; f2B = 0; S12 = 0;
-               float ChaoAB, part1, part2, part3;
-
-       /*      f11 = number of shared OTUs with one observed individual in A and B 
-               f1A, f2A = number of shared OTUs with one or two individuals observed in A 
-               f1B, f2B = number of shared OTUs with one or two individuals observed in B 
-               S12 = number of shared OTUs in A and B  */
-
-               //loop through vectors calculating the f11, f1A, f2A, f1B, f2B, S12 values
-               for (int i = 0; i< sharedA->size(); i++) {
-                       tempA = sharedA->getAbundance(i); //store in temps to avoid calling getAbundance multiple times
-                       tempB = sharedB->getAbundance(i);
-                       if ((tempA != 0) && (tempB != 0)) {//they are shared
-                               S12++; //they are shared
-                               //do both A and B have one
-                               if ((tempA == 1) && (tempB == 1)) { f11++; }
-                               
-                               //does A have one or two
-                               if (tempA == 1)                 { f1A++; }
-                               else if (tempA == 2)    { f2A++; }
+               vector<int> temp; 
+               int numGroups = shared.size();
+               float Chao = 0.0; float leftvalue, rightvalue;
                                
-                               //does B have one or two
-                               if (tempB == 1)                 { f1B++; }
-                               else if (tempB == 2)    { f2B++; }
-
+               // IntNode is defined in mothur.h
+               // The tree used here is a binary tree used to represent the f1+++, f+1++, f++1+, f+++1, f11++, f1+1+... 
+               // combinations required to solve the chao estimator equation for any number of groups.  Conceptually, think
+               // of each node as having a 1 and a + value, or for f2 values a 2 and a + value, and 2 pointers to intnodes, and 2 coeffient values.
+               // The coeffient value is how many times you chose branch 1 to get to that fvalue.
+               // If you choose left you are selecting the 1 or 2 value and right means the + value.  For instance, to find
+               // the number of bins that have f1+1+ you would start at the root, go left, right, left, and select the rightvalue.
+               // the coeffient is 2.  Note: we only set the coeffient in f2 values.
+               
+               //create and initialize trees to 0.
+               initialTree(numGroups); 
+               
+               //loop through vectors calculating the f11, f1A, f2A, f1B, f2B, S12 values
+               for (int i = 0; i < shared[0]->size(); i++) {
+                       //get bin values and calc shared 
+                       bool sharedByAll = true;
+                       temp.clear();
+                       for (int j = 0; j < numGroups; j++) {
+                               temp.push_back(shared[j]->getAbundance(i));
+                               if (temp[j] == 0) { sharedByAll = false; }
+                       }
+                       
+                       //they are shared
+                       if (sharedByAll == true) { 
+                                
+                               // cout << "temp = ";
+                               // for (int h = 0; h < temp.size(); h++) { cout << temp[h] << " "; } cout << endl;
+                               //find f1 and f2values
+                               updateTree(temp);
                        }
                }
-               
-               //checks for divide by zero error
-               if ((f2A == 0) || (f2B == 0)) {
-                       part1 = ((float)(f1A*f1B)/(float)(4*(f2A+1)*(f2B+1)));
-                       part2 = ((float)(f1A*(f1A-1))/(float)(2*f2A+2));
-                       part3 = ((float)(f1B*(f1B-1))/(float)(2*f2B+2));
-               }else {
-                       part1 = ((float)(f1A*f1B)/(float)(4*f2A*f2B));
-                       part2 = ((float)(f1A*f1A)/(float)(2*f2A));
-                       part3 = ((float)(f1B*f1B)/(float)(2*f2B));
+
+                       
+               //cout << "Entering " << endl;
+               //calculate chao1, (numleaves-1) because numleaves contains the ++ values.
+               for (int i = 0; i < numLeaves; i++) {
+                       //divide by zero error
+                       if (f2leaves[i]->lvalue == 0) { f2leaves[i]->lvalue++; }
+                       if (f2leaves[i]->rvalue == 0) { f2leaves[i]->rvalue++; }
+                       
+                       //cout << "f2 leaves ";
+                       //cout << f2leaves[i]->lvalue << f2leaves[i]->rvalue << endl;
+                       
+               //      cout << "f2 leaf coef ";
+                       //cout << f2leaves[i]->lcoef << '\t' << f2leaves[i]->rcoef << endl;
+                       
+               //      cout << "f1 leaves ";
+               //      cout << f1leaves[i]->lvalue << f1leaves[i]->rvalue << endl;
+                       
+                       
+                       leftvalue = (float)(f1leaves[i]->lvalue * f1leaves[i]->lvalue) / (float)((pow(2, (float)f2leaves[i]->lcoef)) * f2leaves[i]->lvalue);
+                       if (i != (numLeaves-1)) {
+                               rightvalue = (float)(f1leaves[i]->rvalue * f1leaves[i]->rvalue) / (float)((pow(2, (float)f2leaves[i]->rcoef)) * f2leaves[i]->rvalue);
+                       }else{
+                               rightvalue = (float)(f1leaves[i]->rvalue);
+                       }
+                       //cout << "left = " << leftvalue << " right = " << rightvalue << endl;
+                       Chao += leftvalue + rightvalue;
                }
                
-               ChaoAB = (float)S12 + (float)(f11*part1) + part2 + part3;
-               data[0] = ChaoAB;
-               
+       //      cout << "exiting " << endl;
+               data[0] = Chao;
                return data;
        }
        catch(exception& e) {
@@ -67,7 +90,197 @@ EstOutput SharedChao1::getValues(SharedRAbundVector* sharedA, SharedRAbundVector
                cout << "An unknown error has occurred in the SharedChao1 class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
                exit(1);
        }       
+}
+
+/***********************************************************************/
+//builds trees structure with n leaf nodes initialized to 0.
+void SharedChao1::initialTree(int n) {  
+       try {
+               // (2^n) / 2. Divide by 2 because each leaf node contains 2 values. One for + and one for 1 or 2.
+               numLeaves = pow(2, (float)n) / 2;
+               numNodes = 2*numLeaves - 1;
+               int countleft = 0;
+               int countright = 1;
+               
+               f1leaves.resize(numNodes);
+               f2leaves.resize(numNodes);
+               
+               //initialize leaf values
+               for (int i = 0; i < numLeaves; i++) {
+                       f1leaves[i] = new IntNode;
+                       f1leaves[i]->lvalue = 0;
+                       f1leaves[i]->rvalue = 0;
+                       f1leaves[i]->left = NULL;
+                       f1leaves[i]->right = NULL;
+                       
+                       f2leaves[i] = new IntNode;
+                       f2leaves[i]->lvalue = 0;
+                       f2leaves[i]->rvalue = 0;
+                       f2leaves[i]->left = NULL;
+                       f2leaves[i]->right = NULL;
+               }
+               
+               //set pointers to children
+               for (int j = numLeaves; j < numNodes; j++) {
+                       f1leaves[j] = new IntNode;
+                       f1leaves[j]->left = f1leaves[countleft];
+                       f1leaves[j]->right = f1leaves[countright];
+                                               
+                       f2leaves[j] = new IntNode;
+                       f2leaves[j]->left = f2leaves[countleft];
+                       f2leaves[j]->right =f2leaves[countright];
+                                               
+                       countleft = countleft + 2;
+                       countright = countright + 2;
+               }
+               
+               //point to root
+               f1root = f1leaves[numNodes-1];
+               
+               //point to root
+               f2root = f2leaves[numNodes-1];
+               
+               //set coeffients
+               setCoef(f2root, 0);
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function initialTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedChao1 class function initialTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
 
+/***********************************************************************/
+//take vector containing the abundance info. for a bin and updates trees.
+void SharedChao1::updateTree(vector<int> bin) { 
+       try {
+               updateBranchf1(f1root, bin, 0);  
+               updateBranchf2(f2root, bin, 0); 
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function updateTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedChao1 class function updateTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
 }
 
 /***********************************************************************/
+void SharedChao1::updateBranchf1(IntNode* node, vector<int> bin, int index) {
+       try {
+               //if you have more than one group
+               if (index == (bin.size()-1)) {
+                       if (bin[index] == 1) { node->lvalue++; node->rvalue++; }
+                       else { node->rvalue++;  }
+               }else {
+                       if (bin[index] == 1) {
+                               //follow path as if you are 1
+                               updateBranchf1(node->left, bin, index+1);
+                       }
+                       //follow path as if you are +
+                       updateBranchf1(node->right, bin, index+1);
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function updateBranchf1. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedChao1 class function updateBranchf1. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
+void SharedChao1::updateBranchf2(IntNode* node, vector<int> bin, int index) {
+       try {
+               //if you have more than one group
+               if (index == (bin.size()-1)) {
+                       if (bin[index] == 2) { node->lvalue++; node->rvalue++; }
+                       else { node->rvalue++;  }
+               }else {
+                       if (bin[index] == 2) {
+                               //follow path as if you are 1
+                               updateBranchf2(node->left, bin, index+1);
+                       }
+                       //follow path as if you are +
+                       updateBranchf2(node->right, bin, index+1);
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function updateBranchf2. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedChao1 class function updateBranchf2. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
+void SharedChao1::setCoef(IntNode* node, int coef) {
+       try {
+               if (node->left != NULL) {
+                       setCoef(node->left, coef+1);
+                       setCoef(node->right, coef);
+               }else {
+                       node->lcoef = coef+1;
+                       node->rcoef = coef;
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedChao1 class Function getCoef. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedChao1 class function getCoef. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
+//for debugging purposes
+void SharedChao1::printTree() {
+       
+       cout << "F1 leaves" << endl;
+       printBranch(f1root);
+       
+       cout << "F2 leaves" << endl;
+       printBranch(f2root);
+
+
+}
+/*****************************************************************/
+void SharedChao1::printBranch(IntNode* node) {
+       try {
+               
+               // you are not a leaf
+               if (node->left != NULL) {
+                       printBranch(node->left);
+                       printBranch(node->right);
+               }else { //you are a leaf
+                       cout << node->lvalue << endl;
+                       cout << node->rvalue << endl;
+               }
+               
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function printBranch. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the Tree class function printBranch. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }               
+}
+
+/*****************************************************************/
+
+
+
+
index 7cca63a8fb48bb9ac9a45757d95436562deff455..243039e3a8822c0b9e7a66b6e17d08fcee56cf34 100644 (file)
@@ -17,12 +17,30 @@ It is a child of the calculator class. */
 
 /***********************************************************************/
 
+
 class SharedChao1 : public Calculator  {
        
-public: 
-       SharedChao1() : Calculator("sharedchao", 3) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       public: 
+               SharedChao1() : Calculator("sharedchao", 3, true) {};
+               EstOutput getValues(SAbundVector*) {return data;};
+               EstOutput getValues(vector<SharedRAbundVector*>);
+       private:
+               IntNode* f1root;
+               IntNode* f2root;
+               vector<IntNode*> f1leaves;
+               vector<IntNode*> f2leaves;
+               int numLeaves;
+               int numNodes;
+
+               void initialTree(int);  //builds trees structure with n leaf nodes initialized to 0.
+               void setCoef(IntNode*, int);
+               void updateTree(vector<int>); //take vector containing the abundance info. for a bin and updates trees.
+               void updateBranchf1(IntNode*, vector<int>, int);  //pointer, vector of abundance values, index into vector
+               void updateBranchf2(IntNode*, vector<int>, int);  //pointer, vector of abundance values, index into vector
+               
+               //for debugging
+               void printTree();
+               void printBranch(IntNode*);
 };
 
 /***********************************************************************/
index 79a57455668b1df99396d17ceb6bf3bcbe0bb2f6..b969e24f4286e794894b04c9897f49a593f67317 100644 (file)
 
 /***********************************************************************/
 
-EstOutput JAbund::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput JAbund::getValues(vector<SharedRAbundVector*> shared) {
        try {
                EstOutput UVest;
                UVest.resize(2,0);
                data.resize(1,0);
                
-               UVest = uv->getUVest(shared1, shared2);
+               UVest = uv->getUVest(shared);
                
                //UVest[0] is Uest UVest[1] is Vest
                data[0] = (UVest[0] * UVest[1]) / ((float)(UVest[0] + UVest[1] - (UVest[0] * UVest[1])));
index 5e4424374e006557e2c6faa7c753f763bcf0dd9c..f01d61659ccc22602431a1f9719f5bafea05f8c5 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class JAbund : public Calculator  {
        
 public:
-       JAbund() :  Calculator("JAbund", 3) {};
+       JAbund() :  Calculator("JAbund", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        UVEst* uv;
        
index 54d87ccc9a39170c5715a29ee73a86453176f7e7..a0ccc8925654335230b32a38858e4fd7d2756788 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput Jclass::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput Jclass::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
@@ -21,10 +21,10 @@ EstOutput Jclass::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sha
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        //find number of bins in shared1 and shared2
                        if (tempA != 0) { S1++; }
index bafc3f76c357c2347778d08b51be84f41c51c20e..45302efe8e18731af5cbbed34383c28ff57e8425 100644 (file)
@@ -19,9 +19,9 @@ It is a child of the calculator class. */
 class Jclass : public Calculator  {
        
 public:
-       Jclass() :  Calculator("Jclass", 3) {};
+       Jclass() :  Calculator("Jclass", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 079cdef11de26892e35942c329a2f8e974131eed..3e370463aba858c2c3a824f4c38e055b800b1fd7 100644 (file)
@@ -14,7 +14,7 @@
 
 /***********************************************************************/
 
-EstOutput Jest::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput Jest::getValues(vector<SharedRAbundVector*> shared) {
        try {
                EstOutput S1, S2, S12;
                S12.resize(1,0);
@@ -32,10 +32,10 @@ EstOutput Jest::getValues(SharedRAbundVector* shared1, SharedRAbundVector* share
                SAbundVector* chaoS1Sabund = new SAbundVector();
                SAbundVector* chaoS2Sabund = new SAbundVector();
                
-               *chaoS1Sabund = shared1->getSAbundVector();
-               *chaoS2Sabund = shared2->getSAbundVector();
+               *chaoS1Sabund = shared[0]->getSAbundVector();
+               *chaoS2Sabund = shared[1]->getSAbundVector();
                
-               S12 = sharedChao->getValues(shared1, shared2);
+               S12 = sharedChao->getValues(shared);
                S1 = chaoS1->getValues(chaoS1Sabund);
                S2 = chaoS2->getValues(chaoS2Sabund);
                                
index fa1f613e610631247b693ae2b4e1ce8be857390b..8a943c900a0bcd6d92edfbe3428cd92e308b606b 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class Jest : public Calculator  {
        
 public:
-       Jest() :  Calculator("Jest", 3) {};
+       Jest() :  Calculator("Jest", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 1da7c90c1e3b4bcda6ae0a0aee70e60995c9c8e8..fefe14f4c192a872d0142cfa81a6a867a10fb32e 100644 (file)
 
 /***********************************************************************/
 
-EstOutput KSTest::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2){
+EstOutput KSTest::getValues(vector<SharedRAbundVector*> shared){
        try {
                data.resize(2,0);
                
                //Must return shared1 and shared2 to original order at conclusion of kstest
-               vector <individual> initData1 = shared1->getData();
-               vector <individual> initData2 = shared2->getData();
-               shared1->sortD();
-               shared2->sortD();
+               vector <individual> initData1 = shared[0]->getData();
+               vector <individual> initData2 = shared[1]->getData();
+               shared[0]->sortD();
+               shared[1]->sortD();
 
-               int numNZ1 = shared1->numNZ();
-               int numNZ2 = shared2->numNZ();
-               double numInd1 = (double)shared1->getNumSeqs();
-               double numInd2 = (double)shared2->getNumSeqs();
+               int numNZ1 = shared[0]->numNZ();
+               int numNZ2 = shared[1]->numNZ();
+               double numInd1 = (double)shared[0]->getNumSeqs();
+               double numInd2 = (double)shared[1]->getNumSeqs();
                
                double maxDiff = -1;
                double sum1 = 0;
                double sum2 = 0;
-               for(int i = 1; i < shared1->getNumBins(); i++)
+               for(int i = 1; i < shared[0]->getNumBins(); i++)
                {
-                       sum1 += shared1->get(i).abundance;
-                       sum2 += shared2->get(i).abundance;
+                       sum1 += shared[0]->get(i).abundance;
+                       sum2 += shared[1]->get(i).abundance;
                        double diff = fabs((double)sum1/numInd1 - (double)sum2/numInd2);
                        if(diff > maxDiff)
                                maxDiff = diff;
@@ -54,8 +54,8 @@ EstOutput KSTest::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sha
                        cout << "If D-Statistic is greater than the critical value then the data sets are significantly different at the 95% confidence level.\n\n";
                }*/
                
-               shared1->setData(initData1);
-               shared2->setData(initData2);
+               shared[0]->setData(initData1);
+               shared[1]->setData(initData2);
                
                data[0] = DStatistic;
                data[1] = critVal;
index 67c85257b026a9bd9852cf76867a0afb1a0c0f1f..6509b5330ad56930df42ee5a7d235eb97b1b31c4 100644 (file)
@@ -18,9 +18,9 @@ It is a child of the calculator class.*/
 class KSTest : public Calculator  {
        
 public:
-       KSTest() : Calculator("kstest", 3) {};
+       KSTest() : Calculator("kstest", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
 };
 
index a4a20a70594bbce286ec2f6d1ac04606b2a2af29..5eadd16691e770453f0ed0053aa3a42ffa3e7b73 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput Kulczynski::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput Kulczynski::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
@@ -21,10 +21,10 @@ EstOutput Kulczynski::getValues(SharedRAbundVector* shared1, SharedRAbundVector*
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        if (tempA != 0) { S1++; }
                        if (tempB != 0) { S2++; } 
index 574ddd59c38f338cc3ee60fbaed6e6ba79dda244..aad69fe716376b2dabe29a3dcc2153ffb92e6209 100644 (file)
@@ -17,9 +17,9 @@
 class Kulczynski : public Calculator  {
        
 public:
-       Kulczynski() :  Calculator("Kulczynski", 1) {};
+       Kulczynski() :  Calculator("Kulczynski", 1, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 66f9d076aa637d8fee5349917fc414c3bdff80f5..7ae67003cce980fe676f2648887ea4fcea23e554 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput KulczynskiCody::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput KulczynskiCody::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
@@ -21,10 +21,10 @@ EstOutput KulczynskiCody::getValues(SharedRAbundVector* shared1, SharedRAbundVec
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        if (tempA != 0) { S1++; }
                        if (tempB != 0) { S2++; } 
index 20ac44e98f374ea50fdf09ca8c988db57e80ad4d..b91dee9a10c4641083aa216d41f96dbb51bb9172 100644 (file)
@@ -18,9 +18,9 @@
 class KulczynskiCody : public Calculator  {
        
 public:
-       KulczynskiCody() :  Calculator("KulczynskiCody", 1) {};
+       KulczynskiCody() :  Calculator("KulczynskiCody", 1, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index b002a68f8a17af79fb04a668f1fd035332c7fa54..4846e20935757e2ed062bf95d56bd229c101fc28 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput Lennon::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput Lennon::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB, min;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; min = 0;
@@ -21,10 +21,10 @@ EstOutput Lennon::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sha
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        if (tempA != 0) { S1++; }
                        if (tempB != 0) { S2++; } 
index 51bc9ed4bbb56b71f99040f91ca5dae276a571ec..0aba6a91802c4a6275475b824c291df2a0cec751 100644 (file)
@@ -18,9 +18,9 @@
 class Lennon : public Calculator  {
        
 public:
-       Lennon() :  Calculator("Lennon", 1) {};
+       Lennon() :  Calculator("Lennon", 1, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 8c5cf9263f32910aaf4f577a9a252e34dcd865d0..eeb01d3b568d414ac23c7341793dfbd06b57a6bc 100644 (file)
@@ -10,7 +10,7 @@
 #include "sharedmorisitahorn.h"
 
 /***********************************************************************/
-EstOutput MorHorn::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput MorHorn::getValues(vector<SharedRAbundVector*> shared) {
        try {   
                data.resize(1,0);
                
@@ -20,17 +20,17 @@ EstOutput MorHorn::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sh
                morhorn = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
                
                //get the total values we need to calculate the theta denominator sums
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       Atotal += shared1->getAbundance(i);
-                       Btotal += shared2->getAbundance(i);
+                       Atotal += shared[0]->getAbundance(i);
+                       Btotal += shared[1]->getAbundance(i);
                }
                
                //calculate the theta denominator sums
-               for (int j = 0; j < shared1->size(); j++) {
+               for (int j = 0; j < shared[0]->size(); j++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(j);
-                       tempB = shared2->getAbundance(j);
+                       tempA = shared[0]->getAbundance(j);
+                       tempB = shared[1]->getAbundance(j);
                        
                        a += tempA * tempA;
                        b += tempB * tempB;
index dd01dc78d322eb02b21118918fe559307305b52b..e771139908615b9430ce58768c16daef6050936d 100644 (file)
@@ -17,9 +17,9 @@
 class MorHorn : public Calculator  {
        
 public:
-       MorHorn() :  Calculator("MorisitaHorn", 1) {};
+       MorHorn() :  Calculator("MorisitaHorn", 1, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 6f38054a2a4110a5123160567f87c8018bee69d9..1809d97e52871b27ad0599856b4d4243e0bf88a3 100644 (file)
 class SharedNSeqs : public Calculator {
 
 public:
-       SharedNSeqs() : Calculator("SharedNSeqs", 1) {};
+       SharedNSeqs() : Calculator("SharedNSeqs", 1, false) {};
        EstOutput getValues(SAbundVector* rank){ return data; };
-       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+       EstOutput getValues(vector<SharedRAbundVector*> shared) {
                data.resize(1,0);
-               data[0] = (double)shared1->getNumSeqs() + (double)shared2->getNumSeqs();
+               data[0] = (double)shared[0]->getNumSeqs() + (double)shared[1]->getNumSeqs();
                return data;
        }
 };
index a9677e5b6731d0c93c50692d106e5bfb36bc6fff..744fb1c2a4b119561bd4756b98ed39483b2c89d1 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput Ochiai::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput Ochiai::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
@@ -21,10 +21,10 @@ EstOutput Ochiai::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sha
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
                        
                        if (tempA != 0) { S1++; }
                        if (tempB != 0) { S2++; } 
index 26c6c586a65c791a56b25325bdb9b9d2c8399315..61d9df38e762b644a8538eddc38cd35da45592ee 100644 (file)
@@ -16,9 +16,9 @@
 class Ochiai : public Calculator  {
        
 public:
-       Ochiai() :  Calculator("Ochiai", 1) {};
+       Ochiai() :  Calculator("Ochiai", 1, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 0a6f095a0345a9865553b2189585b85629bf4697..2830cec3011c4ff713172d198ae03fd93955c0a6 100644 (file)
@@ -341,6 +341,7 @@ SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
 /***********************************************************************/
 
 SharedOrderVector SharedOrderVector::getSharedOrderVector(){
+       random_shuffle(data.begin(), data.end());
        return *this;                   
 }
 
index 9c3f4ddb1d47f1518791d6d95e3f94200823f175..388356ea927c02cee168918026115c010c6d705f 100644 (file)
 //This returns the number of unique species observed in several groups.  
 //The shared vector is each groups sharedrabundvector.
 
-EstOutput SharedSobs::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2){
+EstOutput SharedSobs::getValues(vector<SharedRAbundVector*> shared){
        try {
                data.resize(1,0);
                int observed = 0;
 
                //loop through the species in each group
-               for (int k = 0; k < shared1->size(); k++) {
+               for (int k = 0; k < shared[0]->size(); k++) {
                        //if you have found a new species
-                       if (shared1->getAbundance(k) != 0) { observed++; } 
-                       else if ((shared1->getAbundance(k) == 0) && (shared2->getAbundance(k) != 0)) { observed++; }
+                       if (shared[0]->getAbundance(k) != 0) { observed++; } 
+                       else if ((shared[0]->getAbundance(k) == 0) && (shared[1]->getAbundance(k) != 0)) { observed++; }
                }
 
                data[0] = observed;
index b49119b7c18590f141292c5c91432967422b6de2..e71b6b881033258b5900d41072faf7a6364a3db9 100644 (file)
@@ -19,9 +19,9 @@ It is a child of the calculator class. */
 class SharedSobs : public Calculator {
 
 public:
-       SharedSobs() : Calculator("sharedsobs", 1) {};
+       SharedSobs() : Calculator("sharedsobs", 1, false) {};
        EstOutput getValues(SAbundVector* rank){ return data; };
-       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 };
 
 /***********************************************************************/
index d39e66e58a7bb79b9d4cc5f326b53d169778d181..6815d875fa6d0bf5f1ad88f0fa7e26aeda20568b 100644 (file)
 //This returns the number of shared species observed in several groups.  
 //The shared vector is each groups sharedrabundvector.
 
-EstOutput SharedSobsCS::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2){
+EstOutput SharedSobsCS::getValues(vector<SharedRAbundVector*> shared){
        try {
                data.resize(1,0);
                int observed = 0;
-               int tempA, tempB;
+               int numGroups = shared.size();
 
-               //loop through the species in each group
-               for (int k = 0; k < shared1->size(); k++) {
-                       tempA = shared1->getAbundance(k); //store in temps to avoid calling getAbundance multiple times
-                       tempB = shared2->getAbundance(k);
-
-                       //if you have found a new species
-                       if ((tempA != 0) && (tempB != 0)) {//they are shared
-                               observed++;
+               for (int i = 0; i < shared[0]->size(); i++) {
+                       //get bin values and set sharedByAll 
+                       bool sharedByAll = true;
+                       for (int j = 0; j < numGroups; j++) {
+                               if (shared[j]->getAbundance(i) == 0) { sharedByAll = false; }
                        }
+                       
+                       //they are shared
+                       if (sharedByAll == true) {  observed++;  }
                }
 
                data[0] = observed;
index 016fb6a81f44e447bf5ef1efd8f3efa5b52dc6dd..6c8e7c32c5f55181eed23169fff8cf6bcc9c51ae 100644 (file)
@@ -18,9 +18,9 @@
 class SharedSobsCS : public Calculator {
 
 public:
-       SharedSobsCS() : Calculator("sharedsobs", 1) {};
+       SharedSobsCS() : Calculator("sharedsobs", 1, true) {};
        EstOutput getValues(SAbundVector* rank){ return data; };
-       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 };
 
 /***********************************************************************/
index 36478deab9f91812d44b4a214ea7ff64d037e513..6748bfe86af75f13a5c206577ed5a7f0d51fa6ae 100644 (file)
 
 /***********************************************************************/
 
-EstOutput SorAbund::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput SorAbund::getValues(vector<SharedRAbundVector*> shared) {
        try {
                EstOutput UVest;
                UVest.resize(2,0);
                data.resize(1,0);
                
-               UVest = uv->getUVest(shared1, shared2);
+               UVest = uv->getUVest(shared);
                
                //UVest[0] is Uest, UVest[1] is Vest
                data[0] = (2 * UVest[0] * UVest[1]) / ((float)(UVest[0] + UVest[1]));
index 452471ae4153339f16bdbe6938ab3de38e413e5c..032dbda77c069bef164de7ca7e6accd88a02861f 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class SorAbund : public Calculator  {
        
 public:
-       SorAbund() :  Calculator("SorAbund", 3) {};
+       SorAbund() :  Calculator("SorAbund", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        UVEst* uv;
        
index 4fafe3e8d7b5619a1641b4342355b43b499d8a40..f4757a83ea28a0fff342f4521469a6a43bae44b4 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-EstOutput SorClass::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput SorClass::getValues(vector<SharedRAbundVector*> shared) {
        try {
                int S1, S2, S12, tempA, tempB;
                S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
@@ -21,10 +21,10 @@ EstOutput SorClass::getValues(SharedRAbundVector* shared1, SharedRAbundVector* s
 
                data.resize(1,0);
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
 
                        //find number of bins in shared1 and shared2
                        if (tempA != 0) { S1++; }
index f867b2228271b8bbb8c6cd88db41c0b581621630..16fbed036b54f3ba0e6c3a847a77f624b238f2b5 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class SorClass : public Calculator  {
        
 public:
-       SorClass() :  Calculator("SorClass", 3) {};
+       SorClass() :  Calculator("SorClass", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 68048b10dc5f5f53cbddbbd42873ed01b5edeaaf..429308fc1e457fd469fd1b0eb005b356496a7880 100644 (file)
@@ -13,7 +13,7 @@
 
 /***********************************************************************/
 
-EstOutput SorEst::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput SorEst::getValues(vector<SharedRAbundVector*> shared) {
        try {
                EstOutput S1, S2, S12;
                S12.resize(1,0);
@@ -31,10 +31,10 @@ EstOutput SorEst::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sha
                SAbundVector* chaoS1Sabund = new SAbundVector();
                SAbundVector* chaoS2Sabund = new SAbundVector();
                
-               *chaoS1Sabund = shared1->getSAbundVector();
-               *chaoS2Sabund = shared2->getSAbundVector();
+               *chaoS1Sabund = shared[0]->getSAbundVector();
+               *chaoS2Sabund = shared[1]->getSAbundVector();
                
-               S12 = sharedChao->getValues(shared1, shared2);
+               S12 = sharedChao->getValues(shared);
                S1 = chaoS1->getValues(chaoS1Sabund);
                S2 = chaoS2->getValues(chaoS2Sabund);
                
index 58de55225bc96227f82b21a7666bc5d8554e5b3c..a38cbaecd9f667d460d5801a15e49a524bf9244f 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class SorEst : public Calculator  {
        
 public:
-       SorEst() :  Calculator("SorEst", 3) {};
+       SorEst() :  Calculator("SorEst", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 853bf810f1c37bcd9f325b069db535cf20f92892..0d7405cec5db7c6fd142b4b98619235a2ed74981 100644 (file)
@@ -10,7 +10,7 @@
 #include "sharedthetan.h"
 
 /***********************************************************************/
-EstOutput ThetaN::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput ThetaN::getValues(vector<SharedRAbundVector*> shared) {
        try {   
                data.resize(1,0);
                
@@ -20,17 +20,17 @@ EstOutput ThetaN::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sha
                numerator = 0.0; denominator = 0.0; thetaN = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
                
                //get the total values we need to calculate the theta denominator sums
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       Atotal += shared1->getAbundance(i);
-                       Btotal += shared2->getAbundance(i);
+                       Atotal += shared[0]->getAbundance(i);
+                       Btotal += shared[1]->getAbundance(i);
                }
                
                //calculate the theta denominator sums
-               for (int j = 0; j < shared1->size(); j++) {
+               for (int j = 0; j < shared[0]->size(); j++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(j);
-                       tempB = shared2->getAbundance(j);
+                       tempA = shared[0]->getAbundance(j);
+                       tempB = shared[1]->getAbundance(j);
                        
                        //they are shared
                        if ((tempA != 0) && (tempB != 0)) {
index 459868e2753a9be6dee26f49b969d363ce1df43a..48e816d8e110615fdec4b182a3af7b6b68e7118b 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class ThetaN : public Calculator  {
        
 public:
-       ThetaN() :  Calculator("ThetaN", 3) {};
+       ThetaN() :  Calculator("ThetaN", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 2567110a79fde8ef9499c048927b246b49109ccd..59cea4df6a8835210a33c2d1c815eb50550c6dbc 100644 (file)
@@ -10,7 +10,7 @@
 #include "sharedthetayc.h"
 
 /***********************************************************************/
-EstOutput ThetaYC::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput ThetaYC::getValues(vector<SharedRAbundVector*> shared) {
        try {   
                data.resize(1,0);
                
@@ -23,17 +23,17 @@ EstOutput ThetaYC::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sh
                float b = 0;
                
                //get the total values we need to calculate the theta denominator sums
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       Atotal += shared1->getAbundance(i);
-                       Btotal += shared2->getAbundance(i);
+                       Atotal += shared[0]->getAbundance(i);
+                       Btotal += shared[1]->getAbundance(i);
                }
                
                //calculate the theta denominator sums
-               for (int j = 0; j < shared1->size(); j++) {
+               for (int j = 0; j < shared[0]->size(); j++) {
                        //store in temps to avoid multiple repetitive function calls
-                       relA = shared1->getAbundance(j) / (float)Atotal;
-                       relB = shared2->getAbundance(j) / (float)Btotal;
+                       relA = shared[0]->getAbundance(j) / (float)Atotal;
+                       relB = shared[1]->getAbundance(j) / (float)Btotal;
                                        
                        a += relA * relB;
                        b += pow((relA-relB),2);
index b17d3c4cf858277fe5e10c02a6aa7cb1169f2977..0d9f4a0a94b3ed9bd7bf2d63717d7935ef8ac4d6 100644 (file)
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class ThetaYC : public Calculator  {
        
 public:
-       ThetaYC() :  Calculator("ThetaYC", 3) {};
+       ThetaYC() :  Calculator("ThetaYC", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 private:
        
 };
index 66f4c1328aa93a2db4b4979bb80713d8ad0361d9..699a5d5b37da2c64a60c9e7ddf4c9aafa567bca9 100644 (file)
--- a/simpson.h
+++ b/simpson.h
@@ -20,9 +20,9 @@ It is a child of the calculator class. */
 class Simpson : public Calculator  {
 
 public:
-       Simpson() : Calculator("Simpson", 3) {};
+       Simpson() : Calculator("Simpson", 3, false) {};
        EstOutput getValues(SAbundVector*);
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 };
 
 /***********************************************************************/
diff --git a/sobs.h b/sobs.h
index 528289eb257cabfeeff67eb632c032538377c9a3..2259244796e0cc36dbaf244dfdd69d96c2e66d9e 100644 (file)
--- a/sobs.h
+++ b/sobs.h
@@ -21,13 +21,13 @@ It is a child of the calculator class. */
 class Sobs : public Calculator {
 
 public:
-       Sobs() : Calculator("sobs", 1) {};
+       Sobs() : Calculator("sobs", 1, false) {};
        EstOutput getValues(SAbundVector* rank){
                data.resize(1,0);
                data[0] = (double)rank->getNumBins();
                return data;
        }
-       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
 };
 
 /***********************************************************************/
index eca2033ed6b0f675374e4e855933a8142a6435c5..b3e665085e701b51db3873f7e5f503112c4fc91e 100644 (file)
@@ -41,6 +41,7 @@ SummarySharedCommand::SummarySharedCommand(){
                format = globaldata->getFormat();
                validCalculator = new ValidCalculators();
                util = new SharedUtil();
+               mult = false;
                
                int i;
                for (i=0; i<globaldata->Estimators.size(); i++) {
@@ -88,7 +89,6 @@ SummarySharedCommand::SummarySharedCommand(){
                                }else if (globaldata->Estimators[i] == "whittaker") { 
                                        sumCalculators.push_back(new Whittaker());
                                }
-                               
                        }
                }
                //reset calc for next command
@@ -120,7 +120,13 @@ int SummarySharedCommand::execute(){
                
                //if the users entered no valid calculators don't execute command
                if (sumCalculators.size() == 0) { return 0; }
-
+               //check if any calcs can do multiples
+               else{
+                       for (int i = 0; i < sumCalculators.size(); i++) {
+                               if (sumCalculators[i]->getMultiple() == true) { mult = true; }
+                       }
+               }
+               
                if (format == "sharedfile") {
                        read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
@@ -147,6 +153,20 @@ int SummarySharedCommand::execute(){
                }
                outputFileHandle << endl;
                
+               //create file and put column headers for multiple groups file
+               if (mult = true) {
+                       outAllFileName = ((getRootName(globaldata->inputFileName)) + "sharedmultiple.summary");
+                       openOutputFile(outAllFileName, outAll);
+                       
+                       outAll << "label" <<'\t' << "comparison" << '\t'; 
+                       for(int i=0;i<sumCalculators.size();i++){
+                               if (sumCalculators[i]->getMultiple() == true) { 
+                                       outAll << '\t' << sumCalculators[i]->getName();
+                               }
+                       }
+                       outAll << endl;
+               }
+               
                while(order != NULL){
                
                        if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){                       
@@ -154,15 +174,40 @@ int SummarySharedCommand::execute(){
                                cout << order->getLabel() << '\t' << count << endl;
                                util->getSharedVectors(globaldata->Groups, lookup, order);  //fills group vectors from order vector.  //fills group vectors from order vector.
                                
-                               //randomize group order
-                               if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); }
+                               //loop through calculators and add to file all for all calcs that can do mutiple groups
+                               if (mult = true) {
+                                       //output label
+                                       outAll << order->getLabel() << '\t';
+                                       
+                                       //output groups names
+                                       string outNames = "";
+                                       for (int j = 0; j < lookup.size(); j++) {
+                                               outNames += lookup[j]->getGroup() +  "-";
+                                       }
+                                       outNames = outNames.substr(0, outNames.length()-1); //rip off extra '-';
+                                       outAll << outNames << '\t';
+                                       
+                                       for(int i=0;i<sumCalculators.size();i++){
+                                               if (sumCalculators[i]->getMultiple() == true) { 
+                                                       sumCalculators[i]->getValues(lookup);
+                                                       outAll << '\t';
+                                                       sumCalculators[i]->print(outAll);
+                                               }
+                                       }
+                                       outAll << endl;
+                               }
 
                                int n = 1; 
+                               vector<SharedRAbundVector*> subset;
                                for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                        for (int l = n; l < lookup.size(); l++) {
                                                
                                                outputFileHandle << order->getLabel() << '\t';
                                                
+                                               subset.clear(); //clear out old pair of sharedrabunds
+                                               //add new pair of sharedrabunds
+                                               subset.push_back(lookup[k]); subset.push_back(lookup[l]); 
+                                               
                                                //sort groups to be alphanumeric
                                                if (lookup[k]->getGroup() > lookup[l]->getGroup()) {
                                                        outputFileHandle << (lookup[l]->getGroup() +'\t' + lookup[k]->getGroup()) << '\t'; //print out groups
@@ -170,8 +215,8 @@ int SummarySharedCommand::execute(){
                                                        outputFileHandle << (lookup[k]->getGroup() +'\t' + lookup[l]->getGroup()) << '\t'; //print out groups
                                                }
                                                
-                                               for(int i=0;i<sumCalculators.size();i++){
-                                                       sumCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs
+                                               for(int i=0;i<sumCalculators.size();i++) {
+                                                       sumCalculators[i]->getValues(subset); //saves the calculator outputs
                                                        outputFileHandle << '\t';
                                                        sumCalculators[i]->print(outputFileHandle);
                                                }
index e87e75e6412a36239f3c1b1e19066609aaef4527..ea141d1610c41676cad785690e32b8a16268cbd3 100644 (file)
@@ -53,8 +53,9 @@ private:
        SharedListVector* SharedList;
        SharedOrderVector* order;
        vector<SharedRAbundVector*> lookup;
-       string outputFileName, format;
-       ofstream outputFileHandle;
+       string outputFileName, format, outAllFileName;
+       ofstream outputFileHandle, outAll;
+       bool mult;
 
 };
 
index e50fbaad53f0438a44bc25bf5b7c55fbf9146b83..de30d3c5ac2e30ab6e44cb0f84cdb9e47c1eaf73 100644 (file)
@@ -83,7 +83,8 @@ int TreeGroupCommand::execute(){
        try {
                int count = 1;  
                EstOutput data;
-       
+               vector<SharedRAbundVector*> subset;
+               
                //if the users entered no valid calculators don't execute command
                if (treeCalculators.size() == 0) { return 0; }
 
@@ -150,7 +151,12 @@ int TreeGroupCommand::execute(){
                                                for (int l = k; l < lookup.size(); l++) {
                                                        if (k != l) { //we dont need to similiarity of a groups to itself
                                                                //get estimated similarity between 2 groups
-                                                               data = treeCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs
+                                                               
+                                                               subset.clear(); //clear out old pair of sharedrabunds
+                                                               //add new pair of sharedrabunds
+                                                               subset.push_back(lookup[k]); subset.push_back(lookup[l]); 
+                                                               
+                                                               data = treeCalculators[i]->getValues(subset); //saves the calculator outputs
                                                                //save values in similarity matrix
                                                                simMatrix[k][l] = data[0];
                                                                simMatrix[l][k] = data[0];
index 725bcd1513e13b26f49d8d226aef1b09bc739569..819be0af66bbdb23d989587ee4c6ca676677ea76 100644 (file)
--- a/uvest.cpp
+++ b/uvest.cpp
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 //This is used by SharedJAbund and SharedSorAbund
-EstOutput UVEst::getUVest(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+EstOutput UVEst::getUVest(vector<SharedRAbundVector*> shared) {
        try {   
                EstOutput results;
                results.resize(2,0);
@@ -29,10 +29,10 @@ EstOutput UVEst::getUVest(SharedRAbundVector* shared1, SharedRAbundVector* share
                sumSharedA1 = the sum of all shared otus in A where B = 1
                sumSharedB1 = the sum of all shared otus in B where A = 1 */
                
-               for (int i = 0; i < shared1->size(); i++) {
+               for (int i = 0; i < shared[0]->size(); i++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(i);
-                       tempB = shared2->getAbundance(i);
+                       tempA = shared[0]->getAbundance(i);
+                       tempB = shared[1]->getAbundance(i);
 
                        Atotal += tempA;
                        Btotal += tempB;
diff --git a/uvest.h b/uvest.h
index 3eea438a0e1ff6d6a1444785a30765a18b3fb71c..4f86fedf4bad250b62f7b8a237143a049986482a 100644 (file)
--- a/uvest.h
+++ b/uvest.h
@@ -23,7 +23,7 @@ typedef vector<double> EstOutput;
 /***********************************************************************/
 class UVEst {
        public:
-               EstOutput getUVest(SharedRAbundVector* shared1, SharedRAbundVector* shared2);           
+               EstOutput getUVest(vector<SharedRAbundVector*>);                
 };
 /***********************************************************************/
 
index 696214e236be1b44cfc63335ee9caecc96249ea8..94845c5308ac640c25701d7a70ac2857f1932656 100644 (file)
@@ -38,6 +38,7 @@ ValidCommands::ValidCommands() {
                commands["get.label"]           = "get.label";
                commands["get.line"]            = "get.line";
                commands["bootstrap.shared"]    = "bootstrap.shared";
+               commands["concensus"]                   = "concensus";
                commands["help"]                                = "help"; 
                commands["quit"]                                = "quit"; 
 
index 3fbf307b69918626e097e2e61a11cfcf54244bb4..4234d2dc65375ae5c2c56b75814494c15b566dab 100644 (file)
@@ -247,7 +247,7 @@ void ValidParameters::initCommandParameters() {
                string collectsingleArray[] =  {"freq","line","label","calc","abund"};
                commandParameters["collect.single"] = addParameters(collectsingleArray, sizeof(collectsingleArray)/sizeof(string));
 
-               string collectsharedArray[] =  {"jumble","freq","line","label","calc","groups"};
+               string collectsharedArray[] =  {"freq","line","label","calc","groups"};
                commandParameters["collect.shared"] = addParameters(collectsharedArray, sizeof(collectsharedArray)/sizeof(string));
 
                string getgroupArray[] =  {};
@@ -271,7 +271,7 @@ void ValidParameters::initCommandParameters() {
                string summarysingleArray[] =  {"line","label","calc","abund"};
                commandParameters["summary.single"] = addParameters(summarysingleArray, sizeof(summarysingleArray)/sizeof(string));
 
-               string summarysharedArray[] =  {"jumble","line","label","calc","groups"};
+               string summarysharedArray[] =  {"line","label","calc","groups"};
                commandParameters["summary.shared"] = addParameters(summarysharedArray, sizeof(summarysharedArray)/sizeof(string));
 
                string parsimonyArray[] =  {"random","groups","iters"};
@@ -301,6 +301,9 @@ void ValidParameters::initCommandParameters() {
                string bootstrapArray[] =  {"line","label","calc","groups","iters"};
                commandParameters["bootstrap.shared"] = addParameters(bootstrapArray, sizeof(bootstrapArray)/sizeof(string));
                
+               string concensusArray[] =  {};
+               commandParameters["concensus"] = addParameters(concensusArray, sizeof(concensusArray)/sizeof(string));
+               
                string quitArray[] = {};
                commandParameters["quit"] = addParameters(quitArray, sizeof(quitArray)/sizeof(string));
 
index 7c33dd7a7bb1237480c4e5d95b28187832a7b71d..3c719ece9d3f68d886d4643fbd21f393b6673101 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -69,8 +69,7 @@ void Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
 void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
        try {
                
-               //fills vector of sharedsabunds - lookup
-               //util->getSharedVectors(globaldata->Groups, lookup, sharedorder);  //fills group vectors from order vector.
+               vector<SharedRAbundVector*> subset;
                
                /******************* 1 Group **************************/
                if (lookup.size() == 1) {
@@ -125,13 +124,16 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                        sabundA = new SAbundVector(lookup[0]->getSAbundVector());//  sabundA = &sA;
                        sabundB = new SAbundVector(lookup[1]->getSAbundVector());//  sabundB = &sB;
                        
+                       subset.clear();
+                       subset.push_back(lookup[0]); subset.push_back(lookup[1]);
+                       
                        //make a file for each calculator
                        for(int i=0;i<vCalcs.size();i++){
                                string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
                                openOutputFile(filenamesvg, outsvg);
                                
                                //get estimates for sharedAB
-                               vector<double> shared = vCalcs[i]->getValues(lookup[0], lookup[1]);
+                               vector<double> shared = vCalcs[i]->getValues(subset);
                                
                                //in essence you want to run it like a single 
                                if (vCalcs[i]->getName() == "sharedsobs") {
@@ -199,11 +201,19 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                        for(int i=0;i<vCalcs.size();i++){
                                string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
                                openOutputFile(filenamesvg, outsvg);
-                               
+
                                //get estimates for sharedAB, sharedAC and sharedBC
-                               vector<double> sharedAB = vCalcs[i]->getValues(lookup[0], lookup[1]);
-                               vector<double> sharedAC = vCalcs[i]->getValues(lookup[0], lookup[2]);
-                               vector<double> sharedBC = vCalcs[i]->getValues(lookup[1], lookup[2]);
+                               subset.clear();
+                               subset.push_back(lookup[0]); subset.push_back(lookup[1]);
+                               vector<double> sharedAB = vCalcs[i]->getValues(subset);
+                               
+                               subset.clear();
+                               subset.push_back(lookup[0]); subset.push_back(lookup[2]);
+                               vector<double> sharedAC = vCalcs[i]->getValues(subset);
+                               
+                               subset.clear();
+                               subset.push_back(lookup[1]); subset.push_back(lookup[2]);
+                               vector<double> sharedBC = vCalcs[i]->getValues(subset);
                        
                                //merge BC and estimate with shared with A
                                SharedRAbundVector* merge = new SharedRAbundVector();
@@ -211,7 +221,9 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), j, "");
                                }
                                
-                               vector<double> sharedAwithBC = vCalcs[i]->getValues(lookup[0], merge);
+                               subset.clear();
+                               subset.push_back(lookup[0]); subset.push_back(merge);
+                               vector<double> sharedAwithBC = vCalcs[i]->getValues(subset);
                        
                                delete merge;
                                //merge AC and estimate with shared with B
@@ -219,8 +231,10 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                for (int j = 0; j < lookup[0]->size(); j++) {
                                        merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), j, "");
                                }
-               
-                               vector<double> sharedBwithAC = vCalcs[i]->getValues(lookup[1], merge);
+                               
+                               subset.clear();
+                               subset.push_back(merge); subset.push_back(lookup[1]);
+                               vector<double> sharedBwithAC = vCalcs[i]->getValues(subset);
                        
                                delete merge;
                                //merge AB and estimate with shared with C
@@ -229,7 +243,9 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), j, "");
                                }
                                
-                               vector<double> sharedCwithAB = vCalcs[i]->getValues(lookup[2], merge);
+                               subset.clear();
+                               subset.push_back(lookup[2]); subset.push_back(merge);
+                               vector<double> sharedCwithAB = vCalcs[i]->getValues(subset);
                                delete merge;
                                
                                //in essence you want to run it like a single 
index 95f1c9c5fcb789a19a7496a83177ab639d0067e6..3b179111a854e934b6f9d05e231649796e5565a3 100644 (file)
 
 /***********************************************************************/
 
-EstOutput Whittaker::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2){
+EstOutput Whittaker::getValues(vector<SharedRAbundVector*> shared){
        try{
                data.resize(1);
 
                int countA = 0;
                int countB = 0;
-               int sTotal = shared1->getNumBins();
+               int sTotal = shared[0]->getNumBins();
                for(int i=0;i<sTotal;i++){
-                       if(shared1->getAbundance(i) != 0){      countA++;       }
-                       if(shared2->getAbundance(i) != 0){      countB++;       }               
+                       if(shared[0]->getAbundance(i) != 0){    countA++;       }
+                       if(shared[1]->getAbundance(i) != 0){    countB++;       }               
                }
                
                data[0] = 2*sTotal/(float)(countA+countB)-1;
index 22bf78876efa614b81d68b6a9e2f842a3cd02ac0..bcd72fcc1d9e5f25baa2779aeb71eb553eb0672d 100644 (file)
@@ -18,9 +18,9 @@
 class Whittaker : public Calculator  {
        
 public:
-       Whittaker() : Calculator("whittaker", 3) {};
+       Whittaker() : Calculator("whittaker", 3, false) {};
        EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+       EstOutput getValues(vector<SharedRAbundVector*>);
 
 };