]> git.donarmstrong.com Git - mothur.git/blob - hamming.cpp
mods in testing 1.16.0
[mothur.git] / hamming.cpp
1 /*
2  *  hamming.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 "hamming.h"
11
12 /***********************************************************************/
13 EstOutput Hamming::getValues(vector<SharedRAbundVector*> shared) {
14         try {
15                 data.resize(1,0);
16                 
17                 int numA = 0;
18                 int numB = 0;
19                 int numShared = 0;
20                 
21                 //calc the 2 denominators
22                 for (int i = 0; i < shared[0]->getNumBins(); i++) { 
23                         int A = shared[0]->getAbundance(i);
24                         int B = shared[1]->getAbundance(i);
25                         
26                         if (A != 0) { numA++; }
27                         if (B != 0) { numB++; }
28                         if ((A != 0) && (B != 0)) { numShared++; }
29                 }
30                 
31                 data[0] = numA + numB - (2 * numShared);
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, "Hamming", "getValues");
39                 exit(1);
40         }
41 }
42 /***********************************************************************/
43