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_load_window.hh"
21 do_analysis_cb(Fl_Button* o, void* v)
23 SetupWindow* T=(SetupWindow*)v;
24 T->real_do_analysis();
28 // passes the parameters to the mussa class object and orders it to run
30 SetupWindow::real_do_analysis()
35 // <-- need a check here to make sure all vars have a valid value
38 an_analysis->set_name(ana_name);
39 an_analysis->set_seq_num(seq_num);
40 an_analysis->set_window(window);
41 an_analysis->set_threshold(threshold);
43 for(i=0; i < seq_num; i++)
44 an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
45 sub_seq_starts[i], sub_seq_ends[i]);
47 err_msg = an_analysis->analyze(0,0, 't', 0.0);
48 //cout << "Feel the tribal beat\n";
51 //fl_alert(err_msg.c_str());
62 choose_seq_file_cb(Fl_Button* o, void* v)
64 seq_data_instance * blah = (seq_data_instance *) v;
65 SetupWindow* T= blah->sw_ptr;
66 T->real_choose_seq_file_cb(blah->index);
71 SetupWindow::real_choose_seq_file_cb(int i)
76 picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
77 a_file_path = picked_file;
78 seq_files[i] = a_file_path;
79 seq_inputs[i]->value((const char *)picked_file);
84 seq_file_in_cb(Fl_Input* o, void* v)
86 seq_data_instance * blah = (seq_data_instance *) v;
87 SetupWindow* T= blah->sw_ptr;
88 T->real_seq_file_in_cb(o,blah->index);
93 SetupWindow::real_seq_file_in_cb(Fl_Input* o, int i)
95 seq_files[i] = o->value();
96 // leaving this as a reminder that bools will need to be set to determine
97 // if all needed fields have been filled with some value before an analysis
99 //(*the_motifs)[i].dirty = true;
103 //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
105 // *** Annot file selection
108 choose_annot_file_cb(Fl_Button* o, void* v)
110 seq_data_instance * blah = (seq_data_instance *) v;
111 SetupWindow* T= blah->sw_ptr;
112 T->real_choose_annot_file_cb(blah->index);
117 SetupWindow::real_choose_annot_file_cb(int i)
122 picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
123 a_file_path = picked_file;
124 annot_files[i] = a_file_path;
125 annot_inputs[i]->value((const char *)picked_file);
129 annot_file_in_cb(Fl_Input* o, void* v)
131 seq_data_instance * blah = (seq_data_instance *) v;
132 SetupWindow* T= blah->sw_ptr;
133 T->real_annot_file_in_cb(o,blah->index);
137 SetupWindow::real_annot_file_in_cb(Fl_Input* o, int i)
139 annot_files[i] = o->value();
143 // *** fasta index selection
146 fa_index_in_cb(Fl_Input* o, void* v)
148 seq_data_instance * blah = (seq_data_instance *) v;
149 SetupWindow* T= blah->sw_ptr;
150 T->real_fa_index_in_cb(o,blah->index);
154 SetupWindow::real_fa_index_in_cb(Fl_Input* o, int i)
156 fasta_indices[i] = atoi(o->value());
159 // *** subsequence start select
162 sub_start_in_cb(Fl_Input* o, void* v)
164 seq_data_instance * blah = (seq_data_instance *) v;
165 SetupWindow* T= blah->sw_ptr;
166 T->real_sub_start_in_cb(o,blah->index);
170 SetupWindow::real_sub_start_in_cb(Fl_Input* o, int i)
172 sub_seq_starts[i] = atoi(o->value());
175 // *** subsequence end select
178 sub_end_in_cb(Fl_Input* o, void* v)
180 seq_data_instance * blah = (seq_data_instance *) v;
181 SetupWindow* T= blah->sw_ptr;
182 T->real_sub_end_in_cb(o,blah->index);
186 SetupWindow::real_sub_end_in_cb(Fl_Input* o, int i)
188 sub_seq_ends[i] = atoi(o->value());
192 // *** input analysis name
195 set_ana_name_cb(Fl_Input* o, void* v)
197 SetupWindow* T=(SetupWindow*)v;
198 T->real_set_ana_name_cb(o);
202 SetupWindow::real_set_ana_name_cb(Fl_Input* o)
204 ana_name = o->value();
207 // *** input window size
210 set_win_size_cb(Fl_Input* o, void* v)
212 SetupWindow* T=(SetupWindow*)v;
213 T->real_set_win_size_cb(o);
217 SetupWindow::real_set_win_size_cb(Fl_Input* o)
219 window = atoi(o->value());
222 // *** input threshold
225 set_threshold_cb(Fl_Input* o, void* v)
227 SetupWindow* T=(SetupWindow*)v;
228 T->real_set_threshold_cb(o);
232 SetupWindow::real_set_threshold_cb(Fl_Input* o)
234 threshold = atoi(o->value());
238 set_seq_num_cb(Fl_Input* o, void* v)
240 SetupWindow* T=(SetupWindow*)v;
241 T->real_set_seq_num_cb(o);
244 // *** input number of sequences, add appropriate inputs for each sequence
247 SetupWindow::real_set_seq_num_cb(Fl_Input* o)
251 seq_num = atoi(o->value());
253 annot_inputs.clear();
255 seq_scroll = new Fl_Scroll(5,80,w()-10,h()-115);
256 seq_scroll->color(FL_WHITE);
258 for (i = 0; i < seq_num; i++)
260 seq_files.push_back("");
261 annot_files.push_back("");
262 fasta_indices.push_back(1);
263 sub_seq_starts.push_back(0);
264 sub_seq_ends.push_back(0);
267 seq_scroll->box(FL_DOWN_FRAME);
273 SetupWindow::SetupWindow(int w, int h, const char* title, Mussa *the_analysis):Fl_Window(w,h,title)
277 an_analysis = the_analysis;
282 name_input = new Fl_Input(110, 10, w-120, 30, "Analysis Name ");
283 name_input->value("");
284 //name_input->when(FL_WHEN_ENTER_KEY);
285 name_input->box(FL_BORDER_BOX);
286 name_input->callback((Fl_Callback*)set_ana_name_cb, this);
288 // add in radio buttons for win_append and thres_append eventually
292 win_input = new Fl_Input(65,45,100,30, "Window ");
293 win_input->value("");
294 win_input->callback((Fl_Callback*)set_win_size_cb, this);
296 thres_input = new Fl_Input(250,45,100,30, "Threshold ");
297 thres_input->value("");
298 thres_input->callback((Fl_Callback*)set_threshold_cb, this);
300 seq_num_input = new Fl_Input(430,45,100, 30, "Seq Num ");
301 seq_num_input->value("");
302 seq_num_input->callback((Fl_Callback*)set_seq_num_cb, this);
304 // button to launch the analysis
305 test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
306 test->callback((Fl_Callback*)do_analysis_cb, this);
308 // test button to make sure setup data is being stored
309 test = new Fl_Button(w-200,h-30,100,30,"show setup");
310 test->callback((Fl_Callback*)print_cb, this);
312 // generic input, keeping around as template for future additions
313 //_input = new Fl_Input(0, , 30, "");
315 //_input->when(FL_WHEN_ENTER_KEY);
316 //_input->callback((Fl_Callback*)set__cb, this);
324 SetupWindow::~SetupWindow(){}
328 SetupWindow::add_seq_input(int i)
330 Fl_Input *fasta_input, *start_input, *end_input;
331 Fl_Button *seq_browse, *annot_browse;
334 // this remembers what seq index each input is associated with
335 seq_data_instance * something;
336 something = new seq_data_instance;
337 something->sw_ptr = this;
338 something->index = i;
341 // setup sequence file input for text input or file browsing
342 seq_inputs.push_back(new Fl_Input(55, 85+(i*105), w()-165, 30, "seq "));
343 seq_inputs[i]->value("");
344 seq_inputs[i]->callback((Fl_Callback*)seq_file_in_cb, (void*) something);
346 seq_browse = new Fl_Button(w()-105, 85+(i*105), 80, 30, "Browse");
347 seq_browse->callback((Fl_Callback*)choose_seq_file_cb, (void*) something);
349 // setup annotation file input for text input or file browsing
350 annot_inputs.push_back(new Fl_Input(55, 120+(i*105), w()-165, 30, "annot "));
351 annot_inputs[i]->value("");
352 annot_inputs[i]->callback((Fl_Callback*)annot_file_in_cb,(void*)something);
354 annot_browse = new Fl_Button(w()-105, 120+(i*105), 80, 30, "Browse");
355 annot_browse->callback((Fl_Callback*)choose_annot_file_cb, (void*)something);
357 // index of fasta seq wanted if more than 1 seq in file
358 fasta_input = new Fl_Input(90, 155+(i*105), 50, 30, "fasta index");
359 fasta_input->value("");
360 fasta_input->callback((Fl_Callback*)fa_index_in_cb, (void*) something);
362 // subsequence select, index of first bp wanted
363 start_input = new Fl_Input(225, 155+(i*105), 50, 30, "start index");
364 start_input->value("");
365 start_input->callback((Fl_Callback*)sub_start_in_cb, (void*) something);
367 // subsequence select, index of last bp wanted
368 end_input = new Fl_Input(355, 155+(i*105), 50, 30, "end index");
369 end_input->value("");
370 end_input->callback((Fl_Callback*)sub_end_in_cb, (void*) something);
372 seq_scroll->add(seq_inputs[i]);
373 seq_scroll->add(seq_browse);
374 seq_scroll->add(annot_inputs[i]);
375 seq_scroll->add(annot_browse);
376 seq_scroll->add(fasta_input);
377 seq_scroll->add(start_input);
378 seq_scroll->add(end_input);
388 void SetupWindow::print_cb(Fl_Button* o, void* v)
390 SetupWindow* T=(SetupWindow*)v;
391 T->print_cb_real(o,v);
395 void SetupWindow::print_cb_real(Fl_Button* , void*)
397 cout << "ana_name: " << ana_name << endl;
398 cout << "win: " << window << endl;
399 cout << "thres: " << threshold << endl;
400 cout << "seq_num: " << seq_num << endl;
401 //cout << "win_add: " << win_append << end;
402 //cout << "thres_add: " << thres_append << endl;
408 for (i = 0; i < seq_num; i++)
410 cout << seq_files[i] << endl;
411 cout << annot_files[i] << endl;
412 cout << "fasta: " << fasta_indices[i];
413 cout << " start: " << sub_seq_starts[i];
414 cout << " end: " << sub_seq_ends[i] << endl;
415 cout << "blargle!\n";
417 cout << "end of inputs\n" << endl;