+ if (m->control_pressed) { return 0; }
+
+ //create 2 vectors of sequences, 1 for left side and one for right side
+ vector<Sequence> left; vector<Sequence> right;
+
+ for (int i = 0; i < seqs.size(); i++) {
+
+ if (m->control_pressed) { return 0; }
+
+ //cout << "midpoint = " << midpoint << "\twindow = " << window << endl;
+ //cout << "whole = " << seqs[i]->getAligned().length() << endl;
+ //save left side
+ string seqLeft = seqs[i]->getAligned().substr(midpoint-window, window);
+ Sequence tempLeft;
+ tempLeft.setName(seqs[i]->getName());
+ tempLeft.setAligned(seqLeft);
+ left.push_back(tempLeft);
+ //cout << "left = " << tempLeft.getAligned().length() << endl;
+ //save right side
+ string seqRight = seqs[i]->getAligned().substr(midpoint, window);
+ Sequence tempRight;
+ tempRight.setName(seqs[i]->getName());
+ tempRight.setAligned(seqRight);
+ right.push_back(tempRight);
+ //cout << "right = " << seqRight.length() << endl;
+ }
+
+ //this should be parallelized
+ //perference = sum of (| distance of my left to sequence j's left - distance of my right to sequence j's right | )
+ //create a matrix containing the distance from left to left and right to right
+ //calculate distances
+ SparseMatrix* SparseLeft = new SparseMatrix();
+ SparseMatrix* SparseRight = new SparseMatrix();
+
+ createSparseMatrix(0, left.size(), SparseLeft, left);
+
+ if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
+
+ createSparseMatrix(0, right.size(), SparseRight, right);
+
+ if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
+
+ left.clear(); right.clear();
+ vector<SeqMap> distMapRight;
+ vector<SeqMap> distMapLeft;
+
+ // Create a data structure to quickly access the distance information.
+ //this is from thallingers reimplementation on get.oturep
+ // It consists of a vector of distance maps, where each map contains
+ // all distances of a certain sequence. Vector and maps are accessed
+ // via the index of a sequence in the distance matrix
+ distMapRight = vector<SeqMap>(numSeqs);
+ distMapLeft = vector<SeqMap>(numSeqs);
+ //cout << "left" << endl << endl;
+ for (MatData currentCell = SparseLeft->begin(); currentCell != SparseLeft->end(); currentCell++) {
+ distMapLeft[currentCell->row][currentCell->column] = currentCell->dist;
+ if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
+ //cout << " i = " << currentCell->row << " j = " << currentCell->column << " dist = " << currentCell->dist << endl;
+ }
+ //cout << "right" << endl << endl;
+ for (MatData currentCell = SparseRight->begin(); currentCell != SparseRight->end(); currentCell++) {
+ distMapRight[currentCell->row][currentCell->column] = currentCell->dist;
+ if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
+ //cout << " i = " << currentCell->row << " j = " << currentCell->column << " dist = " << currentCell->dist << endl;
+ }
+
+ delete SparseLeft;
+ delete SparseRight;