X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedsobscollectsummary.cpp;h=204b61c64d779ebe2946d537e5803d9ed36d3d76;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=fffed0290b1136da46e42d31c99542da19ec9a0a;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;p=mothur.git diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index fffed02..204b61c 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->currentSharedBinLabels[i]); } + } + + data[0] = observed; + return data; + } + catch(exception& e) { + m->errorOut(e, "SharedSobsCS", "getValues"); + exit(1); + } +} /***********************************************************************/