5 * Created by Sarah Westcott on 11/18/08.
6 * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
13 /***********************************************************************/
15 void Collect::getCurve(int increment = 1){
17 RAbundVector* lookup = new RAbundVector(order->getNumBins());
18 SAbundVector* rank = new SAbundVector(order->getMaxRank()+1);
20 CollectorsCurveData* ccd = new CollectorsCurveData();
22 for(int i=0;i<displays.size();i++){
23 ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
24 displays[i]->init(label); //sets displays label
26 for(int i=0;i<numSeqs;i++){
28 int binNumber = order->get(i);
29 int abundance = lookup->get(binNumber);
31 rank->set(abundance, rank->get(abundance)-1);
35 lookup->set(binNumber, abundance);
36 rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance)
38 if((i == 0) || (i+1) % increment == 0){
39 ccd->updateRankData(rank);
43 if(numSeqs % increment != 0){
44 ccd->updateRankData(rank);
47 for(int i=0;i<displays.size();i++){
52 cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
56 cout << "An unknown error has occurred in the Collect class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62 /***********************************************************************/
63 void Collect::getSharedCurve(int increment = 1){
65 globaldata = GlobalData::getInstance();
66 vector<SharedRAbundVector*> lookup;
68 //create and initialize vector of sharedvectors, one for each group
69 for (int i = 0; i < globaldata->Groups.size(); i++) {
70 SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
71 temp->setLabel(sharedorder->getLabel());
72 temp->setGroup(globaldata->Groups[i]);
73 temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->Groups[i]]);
74 lookup.push_back(temp);
77 SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData();
79 //initialize labels for output
80 //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C
83 for (int s = 0; s < groupComb.size(); s++) {
84 groupLabel = groupLabel + label + groupComb[s] + "\t";
87 for(int i=0;i<displays.size();i++){
88 ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
89 displays[i]->init(groupLabel);
92 //sample all the members
93 for(int i=0;i<numSeqs;i++){
95 individual chosen = sharedorder->get(i);
98 //set info for sharedvector in chosens group
99 for (int j = 0; j < lookup.size(); j++) {
100 if (chosen.group == lookup[j]->getGroup()) {
101 abundance = lookup[j]->getAbundance(chosen.bin);
102 lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
108 //calculate at 0 and the given increment
109 if((i == 0) || (i+1) % increment == 0){
110 //randomize group order
111 if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); }
112 //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
114 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
115 for (int l = n; l < lookup.size(); l++) {
116 ccd->updateSharedData(lookup[k], lookup[l], i+1, globaldata->Groups.size());
124 //calculate last line if you haven't already
125 if(numSeqs % increment != 0){
126 //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
128 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
129 for (int l = n; l < lookup.size(); l++) {
130 ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, globaldata->Groups.size());
136 //resets output files
137 for(int i=0;i<displays.size();i++){
138 displays[i]->reset();
141 catch(exception& e) {
142 cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
146 cout << "An unknown error has occurred in the Collect class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
152 /**************************************************************************************/
154 void Collect::getGroupComb() {
160 for (int i = 0; i < (globaldata->Groups.size() - 1); i++) {
161 for (int l = n; l < globaldata->Groups.size(); l++) {
162 group = globaldata->Groups[i] + globaldata->Groups[l];
163 groupComb.push_back(group);
171 /**************************************************************************************/