X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedsobscollectsummary.cpp;fp=sharedsobscollectsummary.cpp;h=6815d875fa6d0bf5f1ad88f0fa7e26aeda20568b;hb=50ed3b6104d5821d6184f882e1e1423d47dcbf10;hp=d39e66e58a7bb79b9d4cc5f326b53d169778d181;hpb=17261b0ad578de8aac463dd6977a2d6fdee565a1;p=mothur.git diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index d39e66e..6815d87 100644 --- a/sharedsobscollectsummary.cpp +++ b/sharedsobscollectsummary.cpp @@ -13,21 +13,21 @@ //This returns the number of shared species observed in several groups. //The shared vector is each groups sharedrabundvector. -EstOutput SharedSobsCS::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2){ +EstOutput SharedSobsCS::getValues(vector shared){ try { data.resize(1,0); int observed = 0; - int tempA, tempB; + int numGroups = shared.size(); - //loop through the species in each group - for (int k = 0; k < shared1->size(); k++) { - tempA = shared1->getAbundance(k); //store in temps to avoid calling getAbundance multiple times - tempB = shared2->getAbundance(k); - - //if you have found a new species - if ((tempA != 0) && (tempB != 0)) {//they are shared - observed++; + for (int i = 0; i < shared[0]->size(); i++) { + //get bin values and set sharedByAll + bool sharedByAll = true; + for (int j = 0; j < numGroups; j++) { + if (shared[j]->getAbundance(i) == 0) { sharedByAll = false; } } + + //they are shared + if (sharedByAll == true) { observed++; } } data[0] = observed;