5 * Created by Sarah Westcott on 11/18/08.
6 * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
12 /***********************************************************************/
14 void 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 int binNumber = order->get(i);
28 int abundance = lookup->get(binNumber);
30 rank->set(abundance, rank->get(abundance)-1);
34 lookup->set(binNumber, abundance);
35 rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance)
37 if((i == 0) || (i+1) % increment == 0){
38 ccd->updateRankData(rank);
42 if(numSeqs % increment != 0){
43 ccd->updateRankData(rank);
46 for(int i=0;i<displays.size();i++){
55 errorOut(e, "Collect", "getCurve");
60 /***********************************************************************/
61 void Collect::getSharedCurve(int increment = 1){
63 globaldata = GlobalData::getInstance();
64 vector<SharedRAbundVector*> lookup;
65 vector<SharedRAbundVector*> subset;
67 //create and initialize vector of sharedvectors, one for each group
68 for (int i = 0; i < globaldata->Groups.size(); i++) {
69 SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
70 temp->setLabel(sharedorder->getLabel());
71 temp->setGroup(globaldata->Groups[i]);
72 temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->Groups[i]]);
73 lookup.push_back(temp);
76 SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData();
78 //initialize labels for output
79 //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C
82 for (int s = 0; s < groupComb.size(); s++) {
83 groupLabel = groupLabel + label + groupComb[s] + "\t";
87 string groupLabelAll = groupLabel + label + "all\t";
89 for(int i=0;i<displays.size();i++){
90 ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
91 if ((displays[i]->isCalcMultiple() == true) && (displays[i]->getAll() == true)) { displays[i]->init(groupLabelAll); }
92 else { displays[i]->init(groupLabel); }
95 //sample all the members
96 for(int i=0;i<numSeqs;i++){
98 individual chosen = sharedorder->get(i);
101 //set info for sharedvector in chosens group
102 for (int j = 0; j < lookup.size(); j++) {
103 if (chosen.group == lookup[j]->getGroup()) {
104 abundance = lookup[j]->getAbundance(chosen.bin);
105 lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
110 //calculate at 0 and the given increment
111 if((i == 0) || (i+1) % increment == 0){
113 //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
116 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
117 for (int l = n; l < lookup.size(); l++) {
118 subset.clear(); //clear out old pair of sharedrabunds
119 //add new pair of sharedrabund vectors
120 subset.push_back(lookup[k]); subset.push_back(lookup[l]);
121 ccd->updateSharedData(subset, i+1, globaldata->Groups.size());
125 //if this is a calculator that can do multiples then do them
126 ccd->updateSharedData(lookup, i+1, globaldata->Groups.size());
131 //calculate last label if you haven't already
132 if(numSeqs % increment != 0){
133 //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
135 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
136 for (int l = n; l < lookup.size(); l++) {
137 subset.clear(); //clear out old pair of sharedrabunds
138 //add new pair of sharedrabund vectors
139 subset.push_back(lookup[k]); subset.push_back(lookup[l]);
140 ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size());
144 //if this is a calculator that can do multiples then do them
145 ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size());
148 //resets output files
149 for(int i=0;i<displays.size();i++){
150 displays[i]->reset();
155 for (int i = 0; i < lookup.size(); i++) {
160 catch(exception& e) {
161 errorOut(e, "Collect", "getSharedCurve");
166 /**************************************************************************************/
168 void Collect::getGroupComb() {
174 for (int i = 0; i < (globaldata->Groups.size() - 1); i++) {
175 for (int l = n; l < globaldata->Groups.size(); l++) {
176 group = globaldata->Groups[i] + globaldata->Groups[l];
177 groupComb.push_back(group);
185 /**************************************************************************************/