-}
-/**************************************************************************/
-//shuffles the sequences in the 2 groups passed in.
-void FullMatrix::shuffle(int box){
- try{
- vector<int> rows2Swap;
- vector<int> shuffled;
- float y = 0;
- string name = "";
-
- /****************************/
- //find the box the user wants
- /****************************/
- int count = 0;
- int lowBoundy = bounds[0]; //where first group starts
- int highBoundy = bounds[1]; //where second group starts
- int county = 1; //index in bound
-
- //find the bounds for the box the user wants
- for (int i = 0; i < (numGroups * numGroups); i++) {
-
- //are you at the box?
- if (count == box) { break; }
- else { count++; }
-
- //move to next box
- if (county < numGroups) {
- county++;
- highBoundy = bounds[county];
- lowBoundy = bounds[county-1];
- }else{ //you are moving to a new row of "boxes"
- county = 1;
- highBoundy = bounds[county];
- lowBoundy = bounds[county-1];
- }
- }
-
- /************************/
- //save its rows locations
- /************************/
- //go through the matrix map to find the rows from groups you want to randomize
- for (int y = lowBoundy; y < highBoundy; y++) {
- rows2Swap.push_back(y);
- shuffled.push_back(y);
- }
-
- //randomize rows to shuffle in shuffled
- random_shuffle(shuffled.begin(), shuffled.end());
-
- /***************************************/
- //swap rows and columns to randomize box
- /***************************************/
- for (int i = 0; i < shuffled.size(); i++) {
- //record the swaps you are making so you can undo them in restore function
- restoreIndex[i].a = shuffled[i];
- restoreIndex[i].b = rows2Swap[i];
-
- /* swap rows*/
- for (int h = 0; h < numSeqs; h++) {
- y = matrix[shuffled[i]][h];
- matrix[shuffled[i]][h] = matrix[rows2Swap[i]][h];
- matrix[rows2Swap[i]][h] = y;
- }
-
- /* swap columns */
- for (int b = 0; b < numSeqs; b++) {
- y = matrix[b][shuffled[i]];
- matrix[b][shuffled[i]] = matrix[b][rows2Swap[i]];
- matrix[b][rows2Swap[i]] = y;
- }
-
- //swap map elements
- name = index[shuffled[i]].seqName;
- index[shuffled[i]].seqName = index[rows2Swap[i]].seqName;
- index[rows2Swap[i]].seqName = name;
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the FullMatrix class Function shuffle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the FullMatrix class function shuffle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-/**************************************************************************/
-//unshuffles the matrix.
-void FullMatrix::restore(){
- try{
- float y = 0;
- string name = "";