]> git.donarmstrong.com Git - mothur.git/blob - sharedsobs.cpp
Initial revision
[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(SharedRAbundVector* shared1, SharedRAbundVector* shared2){
17         try {
18                 data.resize(1,0);
19                 int observed = 0;;
20
21                 //loop through the species in each group
22                 for (int k = 0; k < shared1->size(); k++) {
23                         //if you have found a new species
24                         if (shared1->getAbundance(k) != 0) { observed++; } 
25                         else if ((shared1->getAbundance(k) == 0) && (shared2->getAbundance(k) != 0)) { observed++; }
26                 }
27
28                 data[0] = observed;
29                 return data;
30         }
31         catch(exception& e) {
32                 cout << "Standard Error: " << e.what() << " has occurred in the SharedSobs class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
33                 exit(1);
34         }
35         catch(...) {
36                 cout << "An unknown error has occurred in the SharedSobs class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
37                 exit(1);
38         }       
39 }
40
41 /***********************************************************************/