X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedsobscollectsummary.cpp;h=b53b09afc0091e91baf6609aa9c8d5b0ab528b63;hb=bd27c2b0612942815b7417c79f7ee41f669a2a34;hp=0096303d03cd8282e8732046ddc36205a15a1633;hpb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2;p=mothur.git diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index 0096303..b53b09a 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++) { @@ -34,7 +34,37 @@ EstOutput SharedSobsCS::getValues(vector shared){ return data; } catch(exception& e) { - errorOut(e, "SharedSobsCS", "getValues"); + m->errorOut(e, "SharedSobsCS", "getValues"); + 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); } }