]> git.donarmstrong.com Git - mothur.git/blob - sharedsobs.cpp
working on pam
[mothur.git] / sharedsobs.cpp
1 /*
2  *  sharedsobs.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/7/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "sharedsobs.h"
11
12 /***********************************************************************/
13 //This returns the number of unique species observed in several groups.  
14 //The shared vector is each groups sharedrabundvector.
15
16 EstOutput SharedSobs::getValues(vector<SharedRAbundVector*> shared){
17         try {
18                 data.resize(1,0);
19                 double observed = 0;
20
21                 //loop through the species in each group
22                 for (int k = 0; k < shared[0]->getNumBins(); k++) {
23                         //if you have found a new species
24                         if (shared[0]->getAbundance(k) != 0) { observed++; } 
25                         else if ((shared[0]->getAbundance(k) == 0) && (shared[1]->getAbundance(k) != 0)) { observed++; }
26                 }
27
28                 data[0] = observed;
29                 return data;
30         }
31         catch(exception& e) {
32                 m->errorOut(e, "SharedSobs", "getValues");
33                 exit(1);
34         }
35 }
36
37 /***********************************************************************/