X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rarefact.cpp;h=67662496618d427c12363ea5ec120f21578e3f12;hb=a6c698b20eda3671d22466ab6b98b36331a30804;hp=e776393b47318e8a7f9b79016433f75a8ba049d9;hpb=8c548985e92f5be0bde10eddea89a6ae888b73da;p=mothur.git diff --git a/rarefact.cpp b/rarefact.cpp index e776393..6766249 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -8,7 +8,7 @@ */ #include "rarefact.h" -#include "ordervector.hpp" +//#include "ordervector.hpp" /***********************************************************************/ @@ -52,11 +52,15 @@ void Rarefact::getCurve(int increment = 1, int nIters = 1000){ for(int i=0;ireset(); } + + delete lookup; + delete rank; } for(int i=0;iclose(); } + delete rcd; } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -72,65 +76,56 @@ void Rarefact::getCurve(int increment = 1, int nIters = 1000){ void Rarefact::getSharedCurve(int increment = 1, int nIters = 1000){ try { - globaldata = GlobalData::getInstance(); SharedRarefactionCurveData* rcd = new SharedRarefactionCurveData(); + label = lookup[0]->getLabel(); + //register the displays for(int i=0;iregisterDisplay(displays[i]); } - + for(int iter=0;itergGroupmap->getNumGroups(); i++) { - SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins()); - temp->setLabel(sharedorder->getLabel()); - temp->setGroup(globaldata->gGroupmap->namesOfGroups[i]); - lookup.push_back(temp); - } - for(int i=0;iinit(label); } - - //sample all the members - for(int i=0;iget(i); - int abundance; - - //set info for sharedvector in chosens group - for (int j = 0; j < lookup.size(); j++) { - if (chosen.group == lookup[j]->getGroup()) { - abundance = lookup[j]->getAbundance(chosen.bin); - lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); - break; - } - } - } - + //randomize the groups random_shuffle(lookup.begin(), lookup.end()); - + + //make merge the size of lookup[0] + SharedRAbundVector* merge = new SharedRAbundVector(lookup[0]->size()); + + //make copy of lookup zero + for(int i = 0; isize(); i++) { + merge->set(i, lookup[0]->getAbundance(i), "merge"); + } + + vector subset; //send each group one at a time for (int k = 0; k < lookup.size(); k++) { - rcd->updateSharedData(lookup[0], lookup[k], k+1, numGroupComb); - mergeVectors(lookup[0], lookup[k]); + subset.clear(); //clears out old pair of sharedrabunds + //add in new pair of sharedrabunds + subset.push_back(merge); subset.push_back(lookup[k]); + + rcd->updateSharedData(subset, k+1, numGroupComb); + mergeVectors(merge, lookup[k]); } //resets output files for(int i=0;ireset(); } + + delete merge; } for(int i=0;iclose(); } - + + delete rcd; } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -148,9 +143,7 @@ void Rarefact::mergeVectors(SharedRAbundVector* shared1, SharedRAbundVector* sha try{ for (int k = 0; k < shared1->size(); k++) { //merge new species into shared1 - if ((shared1->getAbundance(k) == 0) && (shared2->getAbundance(k) != 0)) { - shared1->set(k, shared2->getAbundance(k), "combo"); //set to 'combo' since this vector now contains multiple groups - } + shared1->set(k, (shared1->getAbundance(k) + shared2->getAbundance(k)), "combo"); //set to 'combo' since this vector now contains multiple groups } } catch(exception& e) {