X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=sharedace.cpp;h=2a06380b6896ae6c908f38222abdcc566bcae077;hp=791b52657859802922d7735d0a52a9144edf368e;hb=1a20e24ee786195ab0e1cccd4f5aede7a88f3f4e;hpb=20a2d0350a737a434c89f303662d64a8eeea7b05 diff --git a/sharedace.cpp b/sharedace.cpp index 791b526..2a06380 100644 --- a/sharedace.cpp +++ b/sharedace.cpp @@ -12,16 +12,16 @@ /***********************************************************************/ -EstOutput SharedAce::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) { +EstOutput SharedAce::getValues(vector shared) { try { data.resize(1,0); string label; - label = shared1->getLabel(); + label = shared[0]->getLabel(); - int fARare, fBRare, S12Rare, S12Abund, S12, f11, tempA, tempB, t10, t01, t11, t21, t12, t22, C12Numerator; + double fARare, fBRare, S12Rare, S12Abund, S12, f11, tempA, tempB, t10, t01, t11, t21, t12, t22, C12Numerator; fARare = 0; fBRare = 0; S12Rare = 0; S12Abund = 0; S12 = 0; f11 = 0; t10 = 0; t01 = 0; t11= 0; t21= 0; t12= 0; t22= 0; C12Numerator = 0; - float SharedAce, C12, part1, part2, part3, part4, part5, Gamma1, Gamma2, Gamma3; + double Sharedace, C12, part1, part2, part3, part4, part5, Gamma1, Gamma2, Gamma3; /*fARare = number of OTUs with one individual found in A and less than or equal to 10 in B. fBRare = number of OTUs with one individual found in B and less than or equal to 10 in A. @@ -32,10 +32,10 @@ EstOutput SharedAce::getValues(SharedRAbundVector* shared1, SharedRAbundVector* S12 = number of shared OTUs in A and B This estimator was changed to reflect Caldwell's changes, eliminating the nrare / nrare - 1 */ - for (int i = 0; i < shared1->size(); i++) { + for (int i = 0; i < shared[0]->getNumBins(); i++) { //store in temps to avoid multiple repetitive function calls - tempA = shared1->getAbundance(i); - tempB = shared2->getAbundance(i); + tempA = shared[0]->getAbundance(i); + tempB = shared[1]->getAbundance(i); if ((tempA != 0) && (tempB != 0)) {//they are shared S12++; //do both A and B have one @@ -77,37 +77,32 @@ EstOutput SharedAce::getValues(SharedRAbundVector* shared1, SharedRAbundVector* C12 = 1 - (C12Numerator /(float) t11); part1 = S12Rare / (float)C12; part2 = 1 / (float)C12; - + //calculate gammas Gamma1 = ((S12Rare * t21) / (float)((C12 * t10 * t11)) - 1); Gamma2 = ((S12Rare * t12) / (float)((C12 * t01 * t11)) - 1); Gamma3 = ((S12Rare / C12) * (S12Rare / C12)) * ( t22 / (float)(t10 * t01 * t11)); Gamma3 = Gamma3 - ((S12Rare * t11) / (float)(C12 * t01 * t10)) - Gamma1 - Gamma2; - + if (isnan(Gamma1) || isinf(Gamma1)) { Gamma1 = 0; } if (isnan(Gamma2) || isinf(Gamma2)) { Gamma2 = 0; } if (isnan(Gamma3) || isinf(Gamma3)) { Gamma3 = 0; } if (isnan(part1) || isinf(part1)) { part1 = 0; } if (isnan(part2) || isinf(part2)) { part2 = 0; } - + part3 = fARare * Gamma1; part4 = fBRare * Gamma2; part5 = f11 * Gamma3; - SharedAce = S12Abund + part1 + (part2 * (part3 + part4 + part5)); - data[0] = SharedAce; + Sharedace = S12Abund + part1 + (part2 * (part3 + part4 + part5)); + data[0] = Sharedace; return data; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedAce class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedAce", "getValues"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SharedAce class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } /***********************************************************************/