5 * Created by Sarah Westcott on 11/18/08.
6 * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
12 /***********************************************************************/
14 int Collect::getCurve(int increment = 1){
16 RAbundVector* lookup = new RAbundVector(order->getNumBins());
17 SAbundVector* rank = new SAbundVector(order->getMaxRank()+1);
19 CollectorsCurveData* ccd = new CollectorsCurveData();
21 for(int i=0;i<displays.size();i++){
22 ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
23 displays[i]->init(label); //sets displays label
25 for(int i=0;i<numSeqs;i++){
27 if (m->control_pressed) { delete lookup; delete rank; delete ccd; return 1; }
29 int binNumber = order->get(i);
30 int abundance = lookup->get(binNumber);
32 rank->set(abundance, rank->get(abundance)-1);
36 lookup->set(binNumber, abundance);
37 rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance)
39 if((i == 0) || (i+1) % increment == 0){
40 ccd->updateRankData(rank);
44 if(numSeqs % increment != 0){
45 ccd->updateRankData(rank);
48 for(int i=0;i<displays.size();i++){
59 m->errorOut(e, "Collect", "getCurve");
64 /***********************************************************************/
65 int Collect::getSharedCurve(int increment = 1){
67 globaldata = GlobalData::getInstance();
68 vector<SharedRAbundVector*> lookup;
69 vector<SharedRAbundVector*> subset;
71 //create and initialize vector of sharedvectors, one for each group
72 for (int i = 0; i < globaldata->Groups.size(); i++) {
73 SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
74 temp->setLabel(sharedorder->getLabel());
75 temp->setGroup(globaldata->Groups[i]);
76 temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->Groups[i]]);
77 lookup.push_back(temp);
80 SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData();
82 //initialize labels for output
83 //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C
86 for (int s = 0; s < groupComb.size(); s++) {
87 groupLabel = groupLabel + label + groupComb[s] + "\t";
91 string groupLabelAll = groupLabel + label + "all\t";
93 for(int i=0;i<displays.size();i++){
94 ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
95 if ((displays[i]->isCalcMultiple() == true) && (displays[i]->getAll() == true)) { displays[i]->init(groupLabelAll); }
96 else { displays[i]->init(groupLabel); }
99 //sample all the members
100 for(int i=0;i<numSeqs;i++){
102 if (m->control_pressed) { for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } delete ccd; return 1; }
105 individual chosen = sharedorder->get(i);
108 //set info for sharedvector in chosens group
109 for (int j = 0; j < lookup.size(); j++) {
110 if (chosen.group == lookup[j]->getGroup()) {
111 abundance = lookup[j]->getAbundance(chosen.bin);
112 lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
117 //calculate at 0 and the given increment
118 if((i == 0) || (i+1) % increment == 0){
120 //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
123 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
124 for (int l = n; l < lookup.size(); l++) {
125 subset.clear(); //clear out old pair of sharedrabunds
126 //add new pair of sharedrabund vectors
127 subset.push_back(lookup[k]); subset.push_back(lookup[l]);
128 ccd->updateSharedData(subset, i+1, globaldata->Groups.size());
132 //if this is a calculator that can do multiples then do them
133 ccd->updateSharedData(lookup, i+1, globaldata->Groups.size());
138 //calculate last label if you haven't already
139 if(numSeqs % increment != 0){
140 //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
142 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
143 for (int l = n; l < lookup.size(); l++) {
144 subset.clear(); //clear out old pair of sharedrabunds
145 //add new pair of sharedrabund vectors
146 subset.push_back(lookup[k]); subset.push_back(lookup[l]);
147 ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size());
151 //if this is a calculator that can do multiples then do them
152 ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size());
155 //resets output files
156 for(int i=0;i<displays.size();i++){
157 displays[i]->reset();
162 for (int i = 0; i < lookup.size(); i++) {
169 catch(exception& e) {
170 m->errorOut(e, "Collect", "getSharedCurve");
175 /**************************************************************************************/
177 void Collect::getGroupComb() {
183 for (int i = 0; i < (globaldata->Groups.size() - 1); i++) {
184 for (int l = n; l < globaldata->Groups.size(); l++) {
185 group = globaldata->Groups[i] + globaldata->Groups[l];
186 groupComb.push_back(group);
194 /**************************************************************************************/