1 // This file is part of the Mussa source distribution.
2 // http://mussa.caltech.edu/
3 // Contact author: Tristan De Buysscher, tristan@caltech.edu
5 // This program and all associated source code files are Copyright (C) 2005
6 // the California Institute of Technology, Pasadena, CA, 91125 USA. It is
7 // under the GNU Public License; please see the included LICENSE.txt
8 // file for more information, or contact Tristan directly.
11 #include "mussa_gui_conn_window.hh"
17 load_ana_cb(Fl_Button* o, void* v)
19 ConnWindow* T=(ConnWindow*)v;
20 T->real_load_ana_cb();
25 ConnWindow::real_load_ana_cb()
31 cout << "Load! Load! Load, ye yellow-bellied seadogs!\n";
32 //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
33 picked_file = fl_dir_chooser("Find an Analysis", "", 1);
34 if (picked_file != NULL)
36 a_file_path = picked_file;
37 cout << "doo wah diddy diddy dum diddy doo\n";
38 cout << a_file_path << endl;
41 an_analysis = new Mussa();
42 err_msg = an_analysis->load(a_file_path);
43 //.substr(0,a_file_path.find(".mu")));
47 // relabel window with the analysis name
48 window_name = "Mussa: " + an_analysis->ana_name;
49 label((const char*)window_name.c_str());
50 // show the user the analysis
51 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
52 an_analysis->window, &(an_analysis->the_Seqs),
53 &(an_analysis->the_paths));
54 conn_box->scale_paths();
58 fl_alert(err_msg.c_str());
59 cout << err_msg << endl;
66 do_ana_cb(Fl_Button* o, void* v)
68 ConnWindow* T=(ConnWindow*)v;
74 ConnWindow::real_do_ana_cb()
80 picked_file = fl_file_chooser("Analysis Config File", "", "", 1);
81 if (picked_file != NULL)
83 a_file_path = picked_file;
85 an_analysis = new Mussa();
86 err_msg = an_analysis->load_mupa_file(a_file_path);
90 err_msg = an_analysis->analyze(0, 0, 't', 0.0);
95 // relabel window with the analysis name
96 window_name = "Mussa: " + an_analysis->ana_name;
97 label((const char*)window_name.c_str());
98 // show the user the analysis
99 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
100 an_analysis->window, &(an_analysis->the_Seqs),
101 &(an_analysis->the_paths));
102 conn_box->scale_paths();
106 fl_alert(err_msg.c_str());
114 setup_ana_cb(Fl_Button* o, void* v)
116 ConnWindow* T=(ConnWindow*)v;
117 T->real_setup_ana_cb();
121 ConnWindow::real_setup_ana_cb()
123 an_analysis = new Mussa();
124 setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
126 while(setup_win->visible())
128 cout << "Like a warm summer day\n";
130 if (setup_win->done())
132 // relabel window with the analysis name
133 window_name = "Mussa: " + an_analysis->ana_name;
134 label((const char*)window_name.c_str());
135 // is it this easy? what if setup window encounters an error...??
136 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
137 an_analysis->window, &(an_analysis->the_Seqs),
138 &(an_analysis->the_paths));
140 conn_box->scale_paths();
146 subana_cb(Fl_Button* o, void* v)
148 ConnWindow* T=(ConnWindow*)v;
153 ConnWindow::real_subana_cb()
157 sub_analysis = new Mussa();
158 subana_win = new SubanaWindow(500,400,"Sub Analysis Setup", sub_analysis,
159 an_analysis->the_Seqs);
161 while(subana_win->visible())
163 cout << "Like a warm summer day\n";
165 if (subana_win->done())
167 subana_name = "SubMussa: " + sub_analysis->ana_name;
168 sub_conn_win = new ConnWindow(w(), h(), (const char*) subana_name.c_str());
169 cout << "Like a warm day in may\n";
170 sub_conn_win->add_ana(sub_analysis);
171 //Fl::visual(FL_DOUBLE|FL_INDEX);
172 //sub_conn_box->show();
178 seq_show_cb(Fl_Button* o, void* v)
180 ConnWindow* T=(ConnWindow*)v;
181 T->real_seq_show_cb();
185 ConnWindow::real_seq_show_cb()
187 show_seq_win = new SeqTextWin(500,400,"Seq Show", an_analysis->the_Seqs);
191 seq_win_spawn_cb(Fl_Button* o, void* v)
193 ConnWindow* T=(ConnWindow*)v;
194 T->real_seq_win_spawn_cb();
198 ConnWindow::real_seq_win_spawn_cb()
200 conn_box->spawnSeq();
204 motif_find_cb(Fl_Button* o, void* v)
206 ConnWindow* T=(ConnWindow*)v;
207 T->real_motif_find_cb();
211 ConnWindow::real_motif_find_cb()
213 conn_box->find_motifs();
217 annot_win_cb(Fl_Button* o, void* v)
219 ConnWindow* T=(ConnWindow*)v;
220 T->real_annot_win_cb();
224 ConnWindow::real_annot_win_cb()
226 conn_box->annot_win();
230 // all the crap needed for dealing with the scale bars
232 toggle_scale_bars_cb(Fl_Button* o, void* v)
234 ConnWindow* T=(ConnWindow*)v;
235 T->real_toggle_bars_cb();
239 ConnWindow::real_toggle_bars_cb()
241 conn_box->toggle_bars();
245 set_bar_len_cb(Fl_Input* o, void* v)
247 ConnWindow* T=(ConnWindow*)v;
248 cout << "WAAAAAAAAA\n";
249 T->real_set_bar_len_cb(o);
253 ConnWindow::real_set_bar_len_cb(Fl_Input* o)
257 new_bar_len = atoi(o->value());
258 cout << "new bar len = " << new_bar_len << endl;
259 conn_box->set_bar_interval(new_bar_len);
263 // all the crap needed for dealing with the scale lines
265 toggle_scale_lines_cb(Fl_Button* o, void* v)
267 ConnWindow* T=(ConnWindow*)v;
268 T->real_toggle_lines_cb();
272 ConnWindow::real_toggle_lines_cb()
274 conn_box->toggle_lines();
278 set_line_len_cb(Fl_Input* o, void* v)
280 ConnWindow* T=(ConnWindow*)v;
281 cout << "WAAAAAAAAA\n";
282 T->real_set_line_len_cb(o);
286 ConnWindow::real_set_line_len_cb(Fl_Input* o)
290 new_line_len = atoi(o->value());
291 cout << "new line len = " << new_line_len << endl;
292 conn_box->set_line_interval(new_line_len);
296 // setting new soft threshold
299 set_soft_thres_cb(Fl_Input* o, void* v)
301 ConnWindow* T=(ConnWindow*)v;
302 cout << "WAAAAAAAAA\n";
303 T->real_set_soft_thres_cb(o);
307 ConnWindow::real_set_soft_thres_cb(Fl_Input* o)
311 new_soft_thres = atoi(o->value());
312 cout << "new soft thres = " << new_soft_thres << endl;
314 an_analysis->set_soft_thres(new_soft_thres);
315 an_analysis->set_ana_mode('t');
317 conn_box->scale_paths();
320 // hacked in stuff to save muway files at different thresholds
322 ostringstream append_info;
324 save_path = an_analysis->ana_name + "/"
325 + an_analysis->ana_name.substr(0,an_analysis->ana_name.find("_t"));
327 append_info << "_t" << new_soft_thres << ".muway";
328 //<< "_w" << an_analysis->window
329 save_path += append_info.str();
330 cout << "saving as: " << save_path << endl;
331 an_analysis->save_muway(save_path);
337 ConnWindow::ConnWindow(int w, int h, const char* title):
338 Fl_Double_Window(w,h,title)
340 int button_len = 120;
341 Fl_Color a_color = fl_rgb_color(150, 200, 255);
346 //fl_color(150,200,255);
351 // create file menu button
352 file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "Analysis");
353 file_menu->color(FL_WHITE,a_color);
354 file_menu->box(FL_BORDER_BOX);
358 file_menu->add("Do Analysis", 0, (Fl_Callback *) do_ana_cb, this);
359 file_menu->add("Load Analysis", 0, (Fl_Callback *) load_ana_cb, this);
360 file_menu->add("Setup Analysis", 0, (Fl_Callback *) setup_ana_cb, this);
361 file_menu->add("Sub Analysis", 0, (Fl_Callback *) subana_cb, this);
364 view_menu = new Fl_Menu_Button(padding+button_len,2, button_len, 30, "View");
365 view_menu->color(FL_WHITE,a_color);
366 view_menu->box(FL_BORDER_BOX);
368 view_menu->add("Sequence Zoom", 0, (Fl_Callback*) seq_win_spawn_cb, this);
369 view_menu->add("Motif Finder", 0, (Fl_Callback*) motif_find_cb, this);
370 view_menu->add("Annotations", 0, (Fl_Callback*) annot_win_cb, this);
371 view_menu->add("Copy Seq", 0, (Fl_Callback*) seq_show_cb, this);
372 view_menu->add("Toggle Bars", 0, (Fl_Callback*) toggle_scale_bars_cb, this,
373 FL_MENU_TOGGLE|FL_MENU_VALUE);
374 view_menu->add("Toggle Lines", 0, (Fl_Callback*) toggle_scale_lines_cb, this,
375 FL_MENU_TOGGLE|FL_MENU_VALUE);
377 bar_input = new Fl_Input(padding+3*button_len, 2, button_len, 30, "Bar Length (bp)");
378 bar_input->value("");
379 bar_input->when(FL_WHEN_ENTER_KEY);
380 bar_input->callback((Fl_Callback*)set_bar_len_cb, this);
382 line_input = new Fl_Input(padding+5*button_len, 2, button_len, 30, "Line Interval (bp)");
383 line_input->value("");
384 line_input->when(FL_WHEN_ENTER_KEY);
385 line_input->callback((Fl_Callback*)set_line_len_cb, this);
388 thres_input = new Fl_Input(padding+7*button_len, 2, button_len, 30, "Threshold");
389 thres_input->value("");
390 thres_input->when(FL_WHEN_ENTER_KEY);
391 thres_input->callback((Fl_Callback*)set_soft_thres_cb, this);
394 // create the connections box
395 conn_box = new ConnView(padding, padding + 30, w-2*padding, h-2*padding-30);
396 //conn_box = new ConnView(padding, padding, w-2*padding, h-2*padding);
403 ConnWindow::~ConnWindow()
408 ConnWindow::add_ana(Mussa *the_ana)
410 an_analysis = the_ana;
412 // relabel window with the analysis name
413 window_name = "Mussa: " + an_analysis->ana_name;
414 label((const char*)window_name.c_str());
416 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
417 an_analysis->window, &(an_analysis->the_Seqs),
418 &(an_analysis->the_paths));
419 conn_box->scale_paths();