X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=sharedsobscollectsummary.cpp;h=b53b09afc0091e91baf6609aa9c8d5b0ab528b63;hp=fffed0290b1136da46e42d31c99542da19ec9a0a;hb=1a20e24ee786195ab0e1cccd4f5aede7a88f3f4e;hpb=53171f07cc0c0e560e2b4ba2946f690d59fc2dc4 diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index fffed02..b53b09a 100644 --- a/sharedsobscollectsummary.cpp +++ b/sharedsobscollectsummary.cpp @@ -38,5 +38,35 @@ EstOutput SharedSobsCS::getValues(vector shared){ exit(1); } } +/***********************************************************************/ +//This returns the number of shared species observed in several groups. +//The shared vector is each groups sharedrabundvector. + +EstOutput SharedSobsCS::getValues(vector shared, vector& labels){ + try { + data.resize(1,0); + double observed = 0; + int numGroups = shared.size(); + labels.clear(); + + for (int i = 0; i < shared[0]->getNumBins(); 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++; labels.push_back(m->currentBinLabels[i]); } + } + + data[0] = observed; + return data; + } + catch(exception& e) { + m->errorOut(e, "SharedSobsCS", "getValues"); + exit(1); + } +} /***********************************************************************/