]> git.donarmstrong.com Git - mothur.git/blob - structkulczynski.cpp
fixes while testing 1.33.0
[mothur.git] / structkulczynski.cpp
1 /*
2  *  structkulczynski.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 12/15/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "structkulczynski.h"
11
12 /***********************************************************************/
13 EstOutput StructKulczynski::getValues(vector<SharedRAbundVector*> shared) {
14         try {
15                 data.resize(1,0);
16                 
17                 double sumA = 0.0;
18                 double sumB = 0.0;
19                 double sumMin = 0.0;
20                 
21                 for (int i = 0; i < shared[0]->getNumBins(); i++) { 
22                         
23                         int A = shared[0]->getAbundance(i);
24                         int B = shared[1]->getAbundance(i);
25                         
26                         sumA += A;
27                         sumB += B;
28                         sumMin += min(A, B);
29                 }
30                 
31                 data[0] = 1.0 - (0.5 * ((sumMin / sumA) + (sumMin / sumB)));
32                 
33                 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
34                 
35                 return data;
36         }
37         catch(exception& e) {
38                 m->errorOut(e, "StructKulczynski", "getValues");
39                 exit(1);
40         }
41 }
42 /***********************************************************************/
43
44