]> git.donarmstrong.com Git - mothur.git/blob - speciesprofile.cpp
working on pam
[mothur.git] / speciesprofile.cpp
1 /*
2  *  speciesprofile.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 "speciesprofile.h"
11
12 /***********************************************************************/
13 EstOutput SpeciesProfile::getValues(vector<SharedRAbundVector*> shared) {
14         try {
15                 data.resize(1,0);
16                 
17                 double sumA = 0.0;
18                 double sumB = 0.0;
19                 
20                 for (int i = 0; i < shared[0]->getNumBins(); i++) { 
21                         sumA += shared[0]->getAbundance(i);
22                         sumB += shared[1]->getAbundance(i);
23                 }
24                 
25                 double sum = 0.0;
26                 for (int i = 0; i < shared[0]->getNumBins(); i++) { 
27                         int A = shared[0]->getAbundance(i);
28                         int B = shared[1]->getAbundance(i);
29                         
30                         sum += (((A / sumA) - (B / sumB)) * ((A / sumA) - (B / sumB)));
31                 }
32                 
33                 data[0] = sqrt(sum);
34                 
35                 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
36                 
37                 return data;
38         }
39         catch(exception& e) {
40                 m->errorOut(e, "SpeciesProfile", "getValues");
41                 exit(1);
42         }
43 }
44 /***********************************************************************/
45