X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=collect.cpp;h=d109ca0540c01a78ca7e08c5c0e7bf6dfad85d90;hb=50ed3b6104d5821d6184f882e1e1423d47dcbf10;hp=1c8128aef4ba42ec11fc2a7edbaa8cd42aa97ced;hpb=addc715b6d7ea52440751cec10edad03e1a19b37;p=mothur.git diff --git a/collect.cpp b/collect.cpp index 1c8128a..d109ca0 100644 --- a/collect.cpp +++ b/collect.cpp @@ -9,177 +9,175 @@ #include "collect.h" - /***********************************************************************/ void Collect::getCurve(int increment = 1){ - try { - RAbundVector* lookup = new RAbundVector(order->getNumBins()); - SAbundVector* rank = new SAbundVector(order->getMaxRank()+1); - - CollectorsCurveData* ccd = new CollectorsCurveData(); - - for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd - displays[i]->init(label); //sets displays label - } - for(int i=0;iget(i); - int abundance = lookup->get(binNumber); - - rank->set(abundance, rank->get(abundance)-1); - - abundance++; - - lookup->set(binNumber, abundance); - rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance) - - if((i == 0) || (i+1) % increment == 0){ - ccd->updateRankData(rank); - } - } - - if(numSeqs % increment != 0){ - ccd->updateRankData(rank); - } - - for(int i=0;ireset(); - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Collect class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } + try { + RAbundVector* lookup = new RAbundVector(order->getNumBins()); + SAbundVector* rank = new SAbundVector(order->getMaxRank()+1); + + CollectorsCurveData* ccd = new CollectorsCurveData(); + + for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd + displays[i]->init(label); //sets displays label + } + for(int i=0;iget(i); + int abundance = lookup->get(binNumber); + + rank->set(abundance, rank->get(abundance)-1); + + abundance++; + + lookup->set(binNumber, abundance); + rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance) + + if((i == 0) || (i+1) % increment == 0){ + ccd->updateRankData(rank); + } + } + + if(numSeqs % increment != 0){ + ccd->updateRankData(rank); + } + + for(int i=0;ireset(); + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the Collect class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } } /***********************************************************************/ void Collect::getSharedCurve(int increment = 1){ try { - globaldata = GlobalData::getInstance(); - vector lookup; - vector chosenGroups = globaldata->sharedGroups; - - //create and initialize vector of sharedvectors, one for each group - for (int i = 0; i < globaldata->gGroupmap->getNumGroups(); i++) { - SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins()); - temp->setLabel(sharedorder->getLabel()); - temp->setGroup(globaldata->gGroupmap->namesOfGroups[i]); - temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->gGroupmap->namesOfGroups[i]]); - lookup.push_back(temp); - } - - SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData(); + globaldata = GlobalData::getInstance(); + vector lookup; + vector subset; + + //create and initialize vector of sharedvectors, one for each group + for (int i = 0; i < globaldata->Groups.size(); i++) { + SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins()); + temp->setLabel(sharedorder->getLabel()); + temp->setGroup(globaldata->Groups[i]); + temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->Groups[i]]); + lookup.push_back(temp); + } + + SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData(); + + //initialize labels for output + //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C + getGroupComb(); + groupLabel = ""; + for (int s = 0; s < groupComb.size(); s++) { + groupLabel = groupLabel + label + groupComb[s] + "\t"; + } + + //for multi displays + string groupLabelAll = groupLabel + label + "all\t"; + + for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd + if (displays[i]->isCalcMultiple() == true) { displays[i]->init(groupLabelAll); } + else { displays[i]->init(groupLabel); } + } + + //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; + } + } + - //initialize labels for output - //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C - getGroupComb(chosenGroups); - groupLabel = ""; - for (int s = 0; s < groupComb.size(); s++) { - groupLabel = groupLabel + label + groupComb[s] + "\t"; - } - - for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd - displays[i]->init(groupLabel); - } - - //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; - } - } - - //calculate at 0 and the given increment - if((i == 0) || (i+1) % increment == 0){ - //randomize group order - if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); } - //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. - int n = 1; - for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare - for (int l = n; l < lookup.size(); l++) { - ccd->updateSharedData(lookup[k], lookup[l], i+1, globaldata->gGroupmap->namesOfGroups.size()); - } - n++; - } - totalNumSeq = i+1; - } - } - - //calculate last line if you haven't already - if(numSeqs % increment != 0){ - //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. - int n = 1; - for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare - for (int l = n; l < lookup.size(); l++) { - ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, globaldata->gGroupmap->namesOfGroups.size()); - } - n++; - } - } - - //resets output files - for(int i=0;ireset(); - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Collect class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } + //calculate at 0 and the given increment + if((i == 0) || (i+1) % increment == 0){ + //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. + int n = 1; + for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare + for (int l = n; l < lookup.size(); l++) { + subset.clear(); //clear out old pair of sharedrabunds + //add new pair of sharedrabund vectors + subset.push_back(lookup[k]); subset.push_back(lookup[l]); + ccd->updateSharedData(subset, i+1, globaldata->Groups.size()); + } + n++; + } + //if this is a calculator that can do multiples then do them + ccd->updateSharedData(lookup, i+1, globaldata->Groups.size()); + } + totalNumSeq = i+1; + } + + //calculate last line if you haven't already + if(numSeqs % increment != 0){ + //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. + int n = 1; + for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare + for (int l = n; l < lookup.size(); l++) { + subset.clear(); //clear out old pair of sharedrabunds + //add new pair of sharedrabund vectors + subset.push_back(lookup[k]); subset.push_back(lookup[l]); + ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size()); + } + n++; + } + //if this is a calculator that can do multiples then do them + ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size()); + } + + //resets output files + for(int i=0;ireset(); + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the Collect class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } } /**************************************************************************************/ -void Collect::getGroupComb(vector chosen) { - string group; - - numGroupComb = 0; - - int n = 1; - for (int i = 0; i < (globaldata->gGroupmap->getNumGroups() - 1); i++) { - for (int l = n; l < globaldata->gGroupmap->getNumGroups(); l++) { - string g1 = globaldata->gGroupmap->namesOfGroups[i]; - string g2 = globaldata->gGroupmap->namesOfGroups[l]; - if(validGroup(chosen, g1) && validGroup(chosen, g2)) { - group = g1 + g2; - groupComb.push_back(group); - numGroupComb++; - } - } - n++; +void Collect::getGroupComb() { + string group; + + numGroupComb = 0; + + int n = 1; + for (int i = 0; i < (globaldata->Groups.size() - 1); i++) { + for (int l = n; l < globaldata->Groups.size(); l++) { + group = globaldata->Groups[i] + globaldata->Groups[l]; + groupComb.push_back(group); + numGroupComb++; } -} - -/**************************************************************************************/ + n++; + } -bool Collect::validGroup(vector chosen, string group) { - if(chosen.size() == 0) - return true; - for(int i = 0; i < chosen.size(); i++) - if(chosen.at(i).compare(group) == 0) - return true; - return false; } - - +/**************************************************************************************/ \ No newline at end of file