X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedsobscollectsummary.cpp;h=b53b09afc0091e91baf6609aa9c8d5b0ab528b63;hb=bd27c2b0612942815b7417c79f7ee41f669a2a34;hp=e2e169c58788dfcd7e9aa313b7105a446bef7867;hpb=e4c80376cc4533f66c8dfc18f3e1a86a60ac17fe;p=mothur.git diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index e2e169c..b53b09a 100644 --- a/sharedsobscollectsummary.cpp +++ b/sharedsobscollectsummary.cpp @@ -19,7 +19,7 @@ EstOutput SharedSobsCS::getValues(vector shared){ 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->currentBinLabels[i]); } + } + + data[0] = observed; + return data; + } + catch(exception& e) { + m->errorOut(e, "SharedSobsCS", "getValues"); + exit(1); + } +} /***********************************************************************/