]> git.donarmstrong.com Git - mothur.git/blob - sharedjest.cpp
changes while testing
[mothur.git] / sharedjest.cpp
1 /*
2  *  sharedjest.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/8/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9  
10 #include "sharedchao1.h"
11 #include "chao1.h"
12 #include "sharedjest.h"
13
14
15 /***********************************************************************/
16
17 EstOutput Jest::getValues(vector<SharedRAbundVector*> shared) {
18         try {
19                 EstOutput S1, S2, S12;
20                 S12.resize(1,0);
21                 S1.resize(3,0);
22                 S2.resize(3,0); 
23                 
24                 /*S1, S2 = number of OTUs estimated in A and B using the Chao estimator
25                 S12 = estimated number of OTUs shared between A and B using the SharedChao estimator*/
26
27                 data.resize(1,0);
28                 
29                 SharedChao1* sharedChao = new SharedChao1();
30                 Chao1* chaoS1 = new Chao1();
31                 Chao1* chaoS2 = new Chao1();
32                 SAbundVector* chaoS1Sabund = new SAbundVector();
33                 SAbundVector* chaoS2Sabund = new SAbundVector();
34                 
35                 *chaoS1Sabund = shared[0]->getSAbundVector();
36                 *chaoS2Sabund = shared[1]->getSAbundVector();
37         
38         //chaoS1Sabund->print(cout);
39         //chaoS2Sabund->print(cout);
40                 
41                 S12 = sharedChao->getValues(shared);
42                 S1 = chaoS1->getValues(chaoS1Sabund);
43                 S2 = chaoS2->getValues(chaoS2Sabund);
44         
45         //cout << S12[0] << '\t' << S1[0] << '\t' << S2[0] << endl;
46                 
47                 data[0] = 1.0 - S12[0] / (float)(S1[0] + S2[0] - S12[0]);
48         //cout << data[0] << endl;
49                 
50                 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
51                 
52                 delete sharedChao;
53                 delete chaoS1;
54                 delete chaoS2;
55                 delete chaoS1Sabund;
56                 delete chaoS2Sabund;
57                 
58                 return data;
59         }
60         catch(exception& e) {
61                 m->errorOut(e, "Jest", "getValues");
62                 exit(1);
63         }
64 }
65
66 /***********************************************************************/