1 #include "mussa_gui_load_window.hh"
11 do_analysis_cb(Fl_Button* o, void* v)
13 SetupWindow* T=(SetupWindow*)v;
14 T->real_do_analysis();
18 // passes the parameters to the mussa class object and orders it to run
20 SetupWindow::real_do_analysis()
25 // <-- need a check here to make sure all vars have a valid value
28 an_analysis->set_name(ana_name);
29 an_analysis->set_seq_num(seq_num);
30 an_analysis->set_window(window);
31 an_analysis->set_threshold(threshold);
33 for(i=0; i < seq_num; i++)
34 an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
35 sub_seq_starts[i], sub_seq_ends[i]);
37 err_msg = an_analysis->analyze(0,0, 't', 0.0);
38 //cout << "Feel the tribal beat\n";
41 //fl_alert(err_msg.c_str());
52 choose_seq_file_cb(Fl_Button* o, void* v)
54 seq_data_instance * blah = (seq_data_instance *) v;
55 SetupWindow* T= blah->sw_ptr;
56 T->real_choose_seq_file_cb(blah->index);
61 SetupWindow::real_choose_seq_file_cb(int i)
66 picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
67 a_file_path = picked_file;
68 seq_files[i] = a_file_path;
69 seq_inputs[i]->value((const char *)picked_file);
74 seq_file_in_cb(Fl_Input* o, void* v)
76 seq_data_instance * blah = (seq_data_instance *) v;
77 SetupWindow* T= blah->sw_ptr;
78 T->real_seq_file_in_cb(o,blah->index);
83 SetupWindow::real_seq_file_in_cb(Fl_Input* o, int i)
85 seq_files[i] = o->value();
86 // leaving this as a reminder that bools will need to be set to determine
87 // if all needed fields have been filled with some value before an analysis
89 //(*the_motifs)[i].dirty = true;
93 //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
95 // *** Annot file selection
98 choose_annot_file_cb(Fl_Button* o, void* v)
100 seq_data_instance * blah = (seq_data_instance *) v;
101 SetupWindow* T= blah->sw_ptr;
102 T->real_choose_annot_file_cb(blah->index);
107 SetupWindow::real_choose_annot_file_cb(int i)
112 picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
113 a_file_path = picked_file;
114 annot_files[i] = a_file_path;
115 annot_inputs[i]->value((const char *)picked_file);
119 annot_file_in_cb(Fl_Input* o, void* v)
121 seq_data_instance * blah = (seq_data_instance *) v;
122 SetupWindow* T= blah->sw_ptr;
123 T->real_annot_file_in_cb(o,blah->index);
127 SetupWindow::real_annot_file_in_cb(Fl_Input* o, int i)
129 annot_files[i] = o->value();
133 // *** fasta index selection
136 fa_index_in_cb(Fl_Input* o, void* v)
138 seq_data_instance * blah = (seq_data_instance *) v;
139 SetupWindow* T= blah->sw_ptr;
140 T->real_fa_index_in_cb(o,blah->index);
144 SetupWindow::real_fa_index_in_cb(Fl_Input* o, int i)
146 fasta_indices[i] = atoi(o->value());
149 // *** subsequence start select
152 sub_start_in_cb(Fl_Input* o, void* v)
154 seq_data_instance * blah = (seq_data_instance *) v;
155 SetupWindow* T= blah->sw_ptr;
156 T->real_sub_start_in_cb(o,blah->index);
160 SetupWindow::real_sub_start_in_cb(Fl_Input* o, int i)
162 sub_seq_starts[i] = atoi(o->value());
165 // *** subsequence end select
168 sub_end_in_cb(Fl_Input* o, void* v)
170 seq_data_instance * blah = (seq_data_instance *) v;
171 SetupWindow* T= blah->sw_ptr;
172 T->real_sub_end_in_cb(o,blah->index);
176 SetupWindow::real_sub_end_in_cb(Fl_Input* o, int i)
178 sub_seq_ends[i] = atoi(o->value());
182 // *** input analysis name
185 set_ana_name_cb(Fl_Input* o, void* v)
187 SetupWindow* T=(SetupWindow*)v;
188 T->real_set_ana_name_cb(o);
192 SetupWindow::real_set_ana_name_cb(Fl_Input* o)
194 ana_name = o->value();
197 // *** input window size
200 set_win_size_cb(Fl_Input* o, void* v)
202 SetupWindow* T=(SetupWindow*)v;
203 T->real_set_win_size_cb(o);
207 SetupWindow::real_set_win_size_cb(Fl_Input* o)
209 window = atoi(o->value());
212 // *** input threshold
215 set_threshold_cb(Fl_Input* o, void* v)
217 SetupWindow* T=(SetupWindow*)v;
218 T->real_set_threshold_cb(o);
222 SetupWindow::real_set_threshold_cb(Fl_Input* o)
224 threshold = atoi(o->value());
228 set_seq_num_cb(Fl_Input* o, void* v)
230 SetupWindow* T=(SetupWindow*)v;
231 T->real_set_seq_num_cb(o);
234 // *** input number of sequences, add appropriate inputs for each sequence
237 SetupWindow::real_set_seq_num_cb(Fl_Input* o)
241 seq_num = atoi(o->value());
243 annot_inputs.clear();
245 seq_scroll = new Fl_Scroll(5,80,w()-10,h()-115);
246 seq_scroll->color(FL_WHITE);
248 for (i = 0; i < seq_num; i++)
250 seq_files.push_back("");
251 annot_files.push_back("");
252 fasta_indices.push_back(1);
253 sub_seq_starts.push_back(0);
254 sub_seq_ends.push_back(0);
257 seq_scroll->box(FL_DOWN_FRAME);
263 SetupWindow::SetupWindow(int w, int h, const char* title, Mussa *the_analysis):Fl_Window(w,h,title)
267 an_analysis = the_analysis;
272 name_input = new Fl_Input(110, 10, w-120, 30, "Analysis Name ");
273 name_input->value("");
274 //name_input->when(FL_WHEN_ENTER_KEY);
275 name_input->box(FL_BORDER_BOX);
276 name_input->callback((Fl_Callback*)set_ana_name_cb, this);
278 // add in radio buttons for win_append and thres_append eventually
282 win_input = new Fl_Input(65,45,100,30, "Window ");
283 win_input->value("");
284 win_input->callback((Fl_Callback*)set_win_size_cb, this);
286 thres_input = new Fl_Input(250,45,100,30, "Threshold ");
287 thres_input->value("");
288 thres_input->callback((Fl_Callback*)set_threshold_cb, this);
290 seq_num_input = new Fl_Input(430,45,100, 30, "Seq Num ");
291 seq_num_input->value("");
292 seq_num_input->callback((Fl_Callback*)set_seq_num_cb, this);
294 // button to launch the analysis
295 test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
296 test->callback((Fl_Callback*)do_analysis_cb, this);
298 // test button to make sure setup data is being stored
299 test = new Fl_Button(w-200,h-30,100,30,"show setup");
300 test->callback((Fl_Callback*)print_cb, this);
302 // generic input, keeping around as template for future additions
303 //_input = new Fl_Input(0, , 30, "");
305 //_input->when(FL_WHEN_ENTER_KEY);
306 //_input->callback((Fl_Callback*)set__cb, this);
314 SetupWindow::~SetupWindow(){}
318 SetupWindow::add_seq_input(int i)
320 Fl_Input *fasta_input, *start_input, *end_input;
321 Fl_Button *seq_browse, *annot_browse;
324 // this remembers what seq index each input is associated with
325 seq_data_instance * something;
326 something = new seq_data_instance;
327 something->sw_ptr = this;
328 something->index = i;
331 // setup sequence file input for text input or file browsing
332 seq_inputs.push_back(new Fl_Input(55, 85+(i*105), w()-165, 30, "seq "));
333 seq_inputs[i]->value("");
334 seq_inputs[i]->callback((Fl_Callback*)seq_file_in_cb, (void*) something);
336 seq_browse = new Fl_Button(w()-105, 85+(i*105), 80, 30, "Browse");
337 seq_browse->callback((Fl_Callback*)choose_seq_file_cb, (void*) something);
339 // setup annotation file input for text input or file browsing
340 annot_inputs.push_back(new Fl_Input(55, 120+(i*105), w()-165, 30, "annot "));
341 annot_inputs[i]->value("");
342 annot_inputs[i]->callback((Fl_Callback*)annot_file_in_cb,(void*)something);
344 annot_browse = new Fl_Button(w()-105, 120+(i*105), 80, 30, "Browse");
345 annot_browse->callback((Fl_Callback*)choose_annot_file_cb, (void*)something);
347 // index of fasta seq wanted if more than 1 seq in file
348 fasta_input = new Fl_Input(90, 155+(i*105), 50, 30, "fasta index");
349 fasta_input->value("");
350 fasta_input->callback((Fl_Callback*)fa_index_in_cb, (void*) something);
352 // subsequence select, index of first bp wanted
353 start_input = new Fl_Input(225, 155+(i*105), 50, 30, "start index");
354 start_input->value("");
355 start_input->callback((Fl_Callback*)sub_start_in_cb, (void*) something);
357 // subsequence select, index of last bp wanted
358 end_input = new Fl_Input(355, 155+(i*105), 50, 30, "end index");
359 end_input->value("");
360 end_input->callback((Fl_Callback*)sub_end_in_cb, (void*) something);
362 seq_scroll->add(seq_inputs[i]);
363 seq_scroll->add(seq_browse);
364 seq_scroll->add(annot_inputs[i]);
365 seq_scroll->add(annot_browse);
366 seq_scroll->add(fasta_input);
367 seq_scroll->add(start_input);
368 seq_scroll->add(end_input);
378 void SetupWindow::print_cb(Fl_Button* o, void* v)
380 SetupWindow* T=(SetupWindow*)v;
381 T->print_cb_real(o,v);
385 void SetupWindow::print_cb_real(Fl_Button* , void*)
387 cout << "ana_name: " << ana_name << endl;
388 cout << "win: " << window << endl;
389 cout << "thres: " << threshold << endl;
390 cout << "seq_num: " << seq_num << endl;
391 //cout << "win_add: " << win_append << end;
392 //cout << "thres_add: " << thres_append << endl;
398 for (i = 0; i < seq_num; i++)
400 cout << seq_files[i] << endl;
401 cout << annot_files[i] << endl;
402 cout << "fasta: " << fasta_indices[i];
403 cout << " start: " << sub_seq_starts[i];
404 cout << " end: " << sub_seq_ends[i] << endl;
405 cout << "blargle!\n";
407 cout << "end of inputs\n" << endl;