- int numSeqs = order->size();
- //sample all the members
- for(int i=0;i<numSeqs;i++){
- //get first sample
- individual chosen = order->get(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;
+ //create and initialize lookup to empty vectors
+ for (int i = 0; i < looktemp.size(); i++) {
+ SharedRAbundVector* temp = new SharedRAbundVector();
+ temp->setLabel(looktemp[i]->getLabel());
+ temp->setGroup(looktemp[i]->getGroup());
+ lookup.push_back(temp);
+
+ //initialize place map
+ place[i] = 0;
+ }
+
+
+ //for each bin
+ for (int i = 0; i < looktemp[0]->size(); i++) {
+ count = 0;
+ bool updatePlace = false;
+ //for each group
+ for (int j = 0; j < looktemp.size(); j++) {
+ if (looktemp[j]->getAbundance(i) != 0) { count++; }
+ }
+
+ //fill lookup
+ for (int j = 0; j < looktemp.size(); j++) {
+ //if they are not shared then push to back, if they are not insert in front
+ if (count < 2) { lookup[j]->push_back(looktemp[j]->getAbundance(i), i, looktemp[j]->getGroup()); }
+ //they are shared by some
+ else { lookup[j]->insert(looktemp[j]->getAbundance(i), place[count], looktemp[j]->getGroup()); updatePlace = true; }
+ }
+
+ if (updatePlace == true) {
+ //move place holders below where you entered up to "make space" for you entry
+ for (it = place.begin(); it!= place.end(); it++) {
+ if (it->first < count) { it->second++; }