X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedsobscollectsummary.cpp;h=204b61c64d779ebe2946d537e5803d9ed36d3d76;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=c64c8259ca25d0a3c585113049ff4877d6630555;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index c64c825..204b61c 100644 --- a/sharedsobscollectsummary.cpp +++ b/sharedsobscollectsummary.cpp @@ -16,10 +16,10 @@ EstOutput SharedSobsCS::getValues(vector shared){ try { data.resize(1,0); - int observed = 0; + double observed = 0; int numGroups = shared.size(); - for (int i = 0; i < shared[0]->size(); i++) { + 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++) { @@ -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); + } +} /***********************************************************************/