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"
15 load_ana_cb(Fl_Button* o, void* v)
17 ConnWindow* T=(ConnWindow*)v;
18 T->real_load_ana_cb();
23 ConnWindow::real_load_ana_cb()
29 cout << "Load! Load! Load, ye yellow-bellied seadogs!\n";
30 //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
31 picked_file = fl_dir_chooser("Find an Analysis", "", 1);
32 if (picked_file != NULL)
34 a_file_path = picked_file;
35 cout << "doo wah diddy diddy dum diddy doo\n";
36 cout << a_file_path << endl;
39 an_analysis = new Mussa();
40 err_msg = an_analysis->load(a_file_path);
41 //.substr(0,a_file_path.find(".mu")));
45 // relabel window with the analysis name
46 window_name = "Mussa: " + an_analysis->ana_name;
47 label((const char*)window_name.c_str());
48 // show the user the analysis
49 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
50 an_analysis->window, &(an_analysis->the_Seqs),
51 &(an_analysis->the_paths));
52 conn_box->scale_paths();
56 fl_alert(err_msg.c_str());
57 cout << err_msg << endl;
64 do_ana_cb(Fl_Button* o, void* v)
66 ConnWindow* T=(ConnWindow*)v;
72 ConnWindow::real_do_ana_cb()
78 picked_file = fl_file_chooser("Analysis Config File", "", "", 1);
79 if (picked_file != NULL)
81 a_file_path = picked_file;
83 an_analysis = new Mussa();
84 err_msg = an_analysis->load_mupa_file(a_file_path);
88 err_msg = an_analysis->analyze(0, 0, 't', 0.0);
93 // relabel window with the analysis name
94 window_name = "Mussa: " + an_analysis->ana_name;
95 label((const char*)window_name.c_str());
96 // show the user the analysis
97 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
98 an_analysis->window, &(an_analysis->the_Seqs),
99 &(an_analysis->the_paths));
100 conn_box->scale_paths();
104 fl_alert(err_msg.c_str());
112 setup_ana_cb(Fl_Button* o, void* v)
114 ConnWindow* T=(ConnWindow*)v;
115 T->real_setup_ana_cb();
119 ConnWindow::real_setup_ana_cb()
121 an_analysis = new Mussa();
122 setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
124 while(setup_win->visible())
126 cout << "Like a warm summer day\n";
128 if (setup_win->done())
130 // relabel window with the analysis name
131 window_name = "Mussa: " + an_analysis->ana_name;
132 label((const char*)window_name.c_str());
133 // is it this easy? what if setup window encounters an error...??
134 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
135 an_analysis->window, &(an_analysis->the_Seqs),
136 &(an_analysis->the_paths));
138 conn_box->scale_paths();
144 subana_cb(Fl_Button* o, void* v)
146 ConnWindow* T=(ConnWindow*)v;
151 ConnWindow::real_subana_cb()
155 sub_analysis = new Mussa();
156 subana_win = new SubanaWindow(500,400,"Sub Analysis Setup", sub_analysis,
157 an_analysis->the_Seqs);
159 while(subana_win->visible())
161 cout << "Like a warm summer day\n";
163 if (subana_win->done())
165 subana_name = "SubMussa: " + sub_analysis->ana_name;
166 sub_conn_win = new ConnWindow(w(), h(), (const char*) subana_name.c_str());
167 cout << "Like a warm day in may\n";
168 sub_conn_win->add_ana(sub_analysis);
169 //Fl::visual(FL_DOUBLE|FL_INDEX);
170 //sub_conn_box->show();
176 seq_show_cb(Fl_Button* o, void* v)
178 ConnWindow* T=(ConnWindow*)v;
179 T->real_seq_show_cb();
183 ConnWindow::real_seq_show_cb()
185 show_seq_win = new SeqTextWin(500,400,"Seq Show", an_analysis->the_Seqs);
189 seq_win_spawn_cb(Fl_Button* o, void* v)
191 ConnWindow* T=(ConnWindow*)v;
192 T->real_seq_win_spawn_cb();
196 ConnWindow::real_seq_win_spawn_cb()
198 conn_box->spawnSeq();
202 motif_find_cb(Fl_Button* o, void* v)
204 ConnWindow* T=(ConnWindow*)v;
205 T->real_motif_find_cb();
209 ConnWindow::real_motif_find_cb()
211 conn_box->find_motifs();
215 annot_win_cb(Fl_Button* o, void* v)
217 ConnWindow* T=(ConnWindow*)v;
218 T->real_annot_win_cb();
222 ConnWindow::real_annot_win_cb()
224 conn_box->annot_win();
228 // all the crap needed for dealing with the scale bars
230 toggle_scale_bars_cb(Fl_Button* o, void* v)
232 ConnWindow* T=(ConnWindow*)v;
233 T->real_toggle_bars_cb();
237 ConnWindow::real_toggle_bars_cb()
239 conn_box->toggle_bars();
243 set_bar_len_cb(Fl_Input* o, void* v)
245 ConnWindow* T=(ConnWindow*)v;
246 cout << "WAAAAAAAAA\n";
247 T->real_set_bar_len_cb(o);
251 ConnWindow::real_set_bar_len_cb(Fl_Input* o)
255 new_bar_len = atoi(o->value());
256 cout << "new bar len = " << new_bar_len << endl;
257 conn_box->set_bar_interval(new_bar_len);
261 // all the crap needed for dealing with the scale lines
263 toggle_scale_lines_cb(Fl_Button* o, void* v)
265 ConnWindow* T=(ConnWindow*)v;
266 T->real_toggle_lines_cb();
270 ConnWindow::real_toggle_lines_cb()
272 conn_box->toggle_lines();
276 set_line_len_cb(Fl_Input* o, void* v)
278 ConnWindow* T=(ConnWindow*)v;
279 cout << "WAAAAAAAAA\n";
280 T->real_set_line_len_cb(o);
284 ConnWindow::real_set_line_len_cb(Fl_Input* o)
288 new_line_len = atoi(o->value());
289 cout << "new line len = " << new_line_len << endl;
290 conn_box->set_line_interval(new_line_len);
294 // setting new soft threshold
297 set_soft_thres_cb(Fl_Input* o, void* v)
299 ConnWindow* T=(ConnWindow*)v;
300 cout << "WAAAAAAAAA\n";
301 T->real_set_soft_thres_cb(o);
305 ConnWindow::real_set_soft_thres_cb(Fl_Input* o)
309 new_soft_thres = atoi(o->value());
310 cout << "new soft thres = " << new_soft_thres << endl;
312 an_analysis->set_soft_thres(new_soft_thres);
313 an_analysis->set_ana_mode('t');
315 conn_box->scale_paths();
318 // hacked in stuff to save muway files at different thresholds
320 ostringstream append_info;
322 save_path = an_analysis->ana_name + "/"
323 + an_analysis->ana_name.substr(0,an_analysis->ana_name.find("_t"));
325 append_info << "_t" << new_soft_thres << ".muway";
326 //<< "_w" << an_analysis->window
327 save_path += append_info.str();
328 cout << "saving as: " << save_path << endl;
329 an_analysis->save_muway(save_path);
335 ConnWindow::ConnWindow(int w, int h, const char* title):
336 Fl_Double_Window(w,h,title)
338 int button_len = 120;
339 Fl_Color a_color = fl_rgb_color(150, 200, 255);
344 //fl_color(150,200,255);
349 // create file menu button
350 file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "Analysis");
351 file_menu->color(FL_WHITE,a_color);
352 file_menu->box(FL_BORDER_BOX);
356 file_menu->add("Do Analysis", 0, (Fl_Callback *) do_ana_cb, this);
357 file_menu->add("Load Analysis", 0, (Fl_Callback *) load_ana_cb, this);
358 file_menu->add("Setup Analysis", 0, (Fl_Callback *) setup_ana_cb, this);
359 file_menu->add("Sub Analysis", 0, (Fl_Callback *) subana_cb, this);
362 view_menu = new Fl_Menu_Button(padding+button_len,2, button_len, 30, "View");
363 view_menu->color(FL_WHITE,a_color);
364 view_menu->box(FL_BORDER_BOX);
366 view_menu->add("Sequence Zoom", 0, (Fl_Callback*) seq_win_spawn_cb, this);
367 view_menu->add("Motif Finder", 0, (Fl_Callback*) motif_find_cb, this);
368 view_menu->add("Annotations", 0, (Fl_Callback*) annot_win_cb, this);
369 view_menu->add("Copy Seq", 0, (Fl_Callback*) seq_show_cb, this);
370 view_menu->add("Toggle Bars", 0, (Fl_Callback*) toggle_scale_bars_cb, this,
371 FL_MENU_TOGGLE|FL_MENU_VALUE);
372 view_menu->add("Toggle Lines", 0, (Fl_Callback*) toggle_scale_lines_cb, this,
373 FL_MENU_TOGGLE|FL_MENU_VALUE);
375 bar_input = new Fl_Input(padding+3*button_len, 2, button_len, 30, "Bar Length (bp)");
376 bar_input->value("");
377 bar_input->when(FL_WHEN_ENTER_KEY);
378 bar_input->callback((Fl_Callback*)set_bar_len_cb, this);
380 line_input = new Fl_Input(padding+5*button_len, 2, button_len, 30, "Line Interval (bp)");
381 line_input->value("");
382 line_input->when(FL_WHEN_ENTER_KEY);
383 line_input->callback((Fl_Callback*)set_line_len_cb, this);
386 thres_input = new Fl_Input(padding+7*button_len, 2, button_len, 30, "Threshold");
387 thres_input->value("");
388 thres_input->when(FL_WHEN_ENTER_KEY);
389 thres_input->callback((Fl_Callback*)set_soft_thres_cb, this);
392 // create the connections box
393 conn_box = new ConnView(padding, padding + 30, w-2*padding, h-2*padding-30);
394 //conn_box = new ConnView(padding, padding, w-2*padding, h-2*padding);
401 ConnWindow::~ConnWindow()
406 ConnWindow::add_ana(Mussa *the_ana)
408 an_analysis = the_ana;
410 // relabel window with the analysis name
411 window_name = "Mussa: " + an_analysis->ana_name;
412 label((const char*)window_name.c_str());
414 conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
415 an_analysis->window, &(an_analysis->the_Seqs),
416 &(an_analysis->the_paths));
417 conn_box->scale_paths();