#include <list>
+#include <vector>
#include <sstream>
#include <QVBoxLayout>
#include "qui/MussaAlignedWindow.hpp"
-
+#include "alg/sequence.hpp"
using namespace std;
setSelectedPaths(m, sel_paths);
setAlignment(0);
browser.zoomToSequence();
+ computeMatchLines();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(&browser);
}
}
+void MussaAlignedWindow::computeMatchLines()
+{
+ const vector<Sequence>& raw_sequence = analysis.sequences();
+ vector<int> aligned_path;
+ int i2, i3;
+ int x_start, x_end;
+ int window_length, win_i;
+ int rc_1 = 0;
+ int rc_2 = 0;
+ bool rc_color;
+ vector<bool> rc_list;
+ bool full_match;
+ vector<bool> matched;
+ int align_counter;
+
+ align_counter = 0;
+ for(vector<ExtendedConservedPath >::iterator pathz_i=selected_paths.begin();
+ pathz_i != selected_paths.end();
+ ++pathz_i)
+ {
+ if (true /* show_aligns[align_counter] */)
+ {
+ ExtendedConservedPath& a_path = *pathz_i;
+ window_length = a_path.window_size;
+ // determine which parts of the path are RC relative to first species
+ rc_list = a_path.reverseComplimented();
+
+ // loop over each bp in the conserved region for all sequences
+ for(win_i = 0; win_i < window_length; win_i++)
+ {
+ aligned_path.clear();
+ // determine which exact base pairs match between the sequences
+ full_match = true;
+ for(i2 = 0; i2 < a_path.size()-1; i2++)
+ {
+ // assume not rc as most likely, adjust below
+ rc_1 = 0;
+ rc_2 = 0;
+ // no matter the case, any RC node needs adjustments
+ if (a_path[i2] < 0)
+ rc_1 = window_length-1;
+ if (a_path[i2+1] < 0)
+ rc_2 = window_length-1;
+
+ x_start = (abs(a_path[i2]-rc_1+win_i));
+ x_end = (abs(a_path[i2+1]-rc_2+win_i));
+
+ // RC case handling
+ // ugh, and xor...only want rc coloring if just one of the nodes is rc
+ // if both nodes are rc, then they are 'normal' relative to each other
+ if ( ( rc_list[i2] || rc_list[i2+1] ) &&
+ !(rc_list[i2] && rc_list[i2+1] ) )
+ { //the hideous rc matching logic - not complex, but annoying
+ if ( !( ( (raw_sequence[i2][x_start] == 'A') &&
+ (raw_sequence[i2+1][x_end] == 'T') ) ||
+ ( (raw_sequence[i2][x_start] == 'T') &&
+ (raw_sequence[i2+1][x_end] == 'A') ) ||
+ ( (raw_sequence[i2][x_start] == 'G') &&
+ (raw_sequence[i2+1][x_end] == 'C') ) ||
+ ( (raw_sequence[i2][x_start] == 'C') &&
+ (raw_sequence[i2+1][x_end] == 'G') ) ) )
+ full_match = false;
+ }
+ else
+ {
+ if (!( (raw_sequence[i2][x_start] == raw_sequence[i2+1][x_end]) &&
+ (raw_sequence[i2][x_start] != 'N') &&
+ (raw_sequence[i2+1][x_end] != 'N') ) )
+ full_match = false;
+ }
+ }
+
+ // draw for matches stretching across all sequences
+ if (full_match)
+ {
+ //fl_line_style(FL_SOLID, 1, NULL);
+
+ // now can draw the line for each bp in this window that matches
+ // grrr, need to ask if anyone cares if I switch the seq
+ // top-bot order...
+ i3 = 0;
+ //y_loc = y_min + 5;
+ for(i2 = 0; i2 < a_path.size()-1; i2++)
+ {
+ // assume not rc as most likely, adjust below
+ rc_1 = 0;
+ rc_2 = 0;
+ // no matter the case, any RC node needs adjustments
+ if (a_path[i2] < 0)
+ {
+ rc_1 = window_length;
+ }
+ if (a_path[i2] < 0)
+ {
+ rc_2 = window_length;
+ }
+
+ // set offset based on current alignment for which bp to show
+ //offset1 = seq_align_offsets[i2];
+ //offset2 = seq_align_offsets[i2+1];
+
+ if ( ( rc_list[i2] || rc_list[i2+1] ) &&
+ !(rc_list[i2] && rc_list[i2+1] ) ) {
+ ;
+ //fl_color(FL_BLUE);
+ } else {
+ ;
+ //fl_color(FL_RED);
+ }
+
+ // maybe shouldn't recalc these, but store values from first loop
+ x_start = (abs((int) (a_path[i2]-rc_1+win_i)));
+ x_end = (abs((int) (a_path[i2+1]-rc_2+win_i)));
+ aligned_path.push_back(x_start);
+ // if we're on the last time through the loop, save x_end too
+ if (i2 == a_path.size()-2) {
+ aligned_path.push_back(x_end);
+ }
+ }
+ }
+ if (aligned_path.size() > 0) {
+ browser.link(aligned_path, rc_list,1);
+ }
+ }
+ }
+ align_counter++;
+ }
+}
+