- for(int i = 0; i < numLeaves; i++) {
- int z;
- //get random index to switch with
- z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
-
- //you only want to randomize the nodes that are from a group the user wants analyzed, so
- //if either of the leaf nodes you are about to switch are not in the users groups then you don't want to switch them.
- if (((tree[z].getGroup() == groupA) || (tree[z].getGroup() == groupB)) && ((tree[i].getGroup() == groupA) || (tree[i].getGroup() == groupB))) {
- //switches node i and node z's info.
- map<string,int> lib_hold = tree[z].pGroups;
- tree[z].pGroups = (tree[i].pGroups);
- tree[i].pGroups = (lib_hold);
-
- string zgroup = tree[z].getGroup();
- tree[z].setGroup(tree[i].getGroup());
- tree[i].setGroup(zgroup);
-
- string zname = tree[z].getName();
- tree[z].setName(tree[i].getName());
- tree[i].setName(zname);
+ int numSeqsA = globaldata->gTreemap->seqsPerGroup[groupA];
+ int numSeqsB = globaldata->gTreemap->seqsPerGroup[groupB];
+
+ vector<string> randomGroups(numSeqsA+numSeqsB, groupA);
+ for(int i=numSeqsA;i<randomGroups.size();i++){
+ randomGroups[i] = groupB;
+ }
+ random_shuffle(randomGroups.begin(), randomGroups.end());