]> git.donarmstrong.com Git - mothur.git/blob - sharedmarczewski.cpp
changed random forest output filename
[mothur.git] / sharedmarczewski.cpp
1 /*
2  *  sharedmarczewski.cpp
3  *  Mothur
4  *
5  *  Created by Thomas Ryabin on 4/8/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "sharedmarczewski.h"
11
12 EstOutput SharedMarczewski::getValues(vector<SharedRAbundVector*> vectorShared){
13         try {
14                 SharedRAbundVector* shared1 = vectorShared[0];
15                 SharedRAbundVector* shared2 = vectorShared[1];
16                 
17                 data.resize(1,0);
18                 
19                 double a = 0;
20                 double b = 0;
21                 double c = 0;
22                 for(int i = 1; i < shared1->size(); i++)
23                 {
24                         int abund1 = shared1->get(i).abundance;
25                         int abund2 = shared2->get(i).abundance;
26                         
27                         if(abund1 > 0 && abund2 > 0)
28                                 a++;
29                         else if(abund1 > 0 && abund2 == 0)
30                                 b++;
31                         else if(abund1 == 0 && abund2 > 0)
32                                 c++;
33                 }
34                 data[0] = (b+c)/(a+b+c);
35
36                 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
37                 
38                 return data;
39         }
40         catch(exception& e) {
41                 m->errorOut(e, "SharedMarczewski", "getValues");
42                 exit(1);
43         }
44 }
45
46 /***********************************************************************/