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"
14 #include <FL/Fl_File_Chooser.H>
26 do_analysis_cb(Fl_Button* o, void* v)
28 SetupWindow* T=(SetupWindow*)v;
29 T->real_do_analysis();
33 // passes the parameters to the mussa class object and orders it to run
35 SetupWindow::real_do_analysis()
40 // <-- need a check here to make sure all vars have a valid value
43 an_analysis->set_name(ana_name);
44 an_analysis->set_seq_num(seq_num);
45 an_analysis->set_window(window);
46 an_analysis->set_threshold(threshold);
48 for(i=0; i < seq_num; i++)
49 an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
50 sub_seq_starts[i], sub_seq_ends[i]);
52 err_msg = an_analysis->analyze(0,0, 't', 0.0);
53 //cout << "Feel the tribal beat\n";
56 //fl_alert(err_msg.c_str());
67 choose_seq_file_cb(Fl_Button* o, void* v)
69 seq_data_instance * blah = (seq_data_instance *) v;
70 SetupWindow* T= blah->sw_ptr;
71 T->real_choose_seq_file_cb(blah->index);
76 SetupWindow::real_choose_seq_file_cb(int i)
81 picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
82 a_file_path = picked_file;
83 seq_files[i] = a_file_path;
84 seq_inputs[i]->value((const char *)picked_file);
89 seq_file_in_cb(Fl_Input* o, void* v)
91 seq_data_instance * blah = (seq_data_instance *) v;
92 SetupWindow* T= blah->sw_ptr;
93 T->real_seq_file_in_cb(o,blah->index);
98 SetupWindow::real_seq_file_in_cb(Fl_Input* o, int i)
100 seq_files[i] = o->value();
101 // leaving this as a reminder that bools will need to be set to determine
102 // if all needed fields have been filled with some value before an analysis
104 //(*the_motifs)[i].dirty = true;
108 //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
110 // *** Annot file selection
113 choose_annot_file_cb(Fl_Button* o, void* v)
115 seq_data_instance * blah = (seq_data_instance *) v;
116 SetupWindow* T= blah->sw_ptr;
117 T->real_choose_annot_file_cb(blah->index);
122 SetupWindow::real_choose_annot_file_cb(int i)
127 picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
128 a_file_path = picked_file;
129 annot_files[i] = a_file_path;
130 annot_inputs[i]->value((const char *)picked_file);
134 annot_file_in_cb(Fl_Input* o, void* v)
136 seq_data_instance * blah = (seq_data_instance *) v;
137 SetupWindow* T= blah->sw_ptr;
138 T->real_annot_file_in_cb(o,blah->index);
142 SetupWindow::real_annot_file_in_cb(Fl_Input* o, int i)
144 annot_files[i] = o->value();
148 // *** fasta index selection
151 fa_index_in_cb(Fl_Input* o, void* v)
153 seq_data_instance * blah = (seq_data_instance *) v;
154 SetupWindow* T= blah->sw_ptr;
155 T->real_fa_index_in_cb(o,blah->index);
159 SetupWindow::real_fa_index_in_cb(Fl_Input* o, int i)
161 fasta_indices[i] = atoi(o->value());
164 // *** subsequence start select
167 sub_start_in_cb(Fl_Input* o, void* v)
169 seq_data_instance * blah = (seq_data_instance *) v;
170 SetupWindow* T= blah->sw_ptr;
171 T->real_sub_start_in_cb(o,blah->index);
175 SetupWindow::real_sub_start_in_cb(Fl_Input* o, int i)
177 sub_seq_starts[i] = atoi(o->value());
180 // *** subsequence end select
183 sub_end_in_cb(Fl_Input* o, void* v)
185 seq_data_instance * blah = (seq_data_instance *) v;
186 SetupWindow* T= blah->sw_ptr;
187 T->real_sub_end_in_cb(o,blah->index);
191 SetupWindow::real_sub_end_in_cb(Fl_Input* o, int i)
193 sub_seq_ends[i] = atoi(o->value());
197 // *** input analysis name
200 set_ana_name_cb(Fl_Input* o, void* v)
202 SetupWindow* T=(SetupWindow*)v;
203 T->real_set_ana_name_cb(o);
207 SetupWindow::real_set_ana_name_cb(Fl_Input* o)
209 ana_name = o->value();
212 // *** input window size
215 set_win_size_cb(Fl_Input* o, void* v)
217 SetupWindow* T=(SetupWindow*)v;
218 T->real_set_win_size_cb(o);
222 SetupWindow::real_set_win_size_cb(Fl_Input* o)
224 window = atoi(o->value());
227 // *** input threshold
230 set_threshold_cb(Fl_Input* o, void* v)
232 SetupWindow* T=(SetupWindow*)v;
233 T->real_set_threshold_cb(o);
237 SetupWindow::real_set_threshold_cb(Fl_Input* o)
239 threshold = atoi(o->value());
243 set_seq_num_cb(Fl_Input* o, void* v)
245 SetupWindow* T=(SetupWindow*)v;
246 T->real_set_seq_num_cb(o);
249 // *** input number of sequences, add appropriate inputs for each sequence
252 SetupWindow::real_set_seq_num_cb(Fl_Input* o)
256 seq_num = atoi(o->value());
258 annot_inputs.clear();
260 seq_scroll = new Fl_Scroll(5,80,w()-10,h()-115);
261 seq_scroll->color(FL_WHITE);
263 for (i = 0; i < seq_num; i++)
265 seq_files.push_back("");
266 annot_files.push_back("");
267 fasta_indices.push_back(1);
268 sub_seq_starts.push_back(0);
269 sub_seq_ends.push_back(0);
272 seq_scroll->box(FL_DOWN_FRAME);
278 SetupWindow::SetupWindow(int w, int h, const char* title, Mussa *the_analysis):Fl_Window(w,h,title)
282 an_analysis = the_analysis;
287 name_input = new Fl_Input(110, 10, w-120, 30, "Analysis Name ");
288 name_input->value("");
289 //name_input->when(FL_WHEN_ENTER_KEY);
290 name_input->box(FL_BORDER_BOX);
291 name_input->callback((Fl_Callback*)set_ana_name_cb, this);
293 // add in radio buttons for win_append and thres_append eventually
297 win_input = new Fl_Input(65,45,100,30, "Window ");
298 win_input->value("");
299 win_input->callback((Fl_Callback*)set_win_size_cb, this);
301 thres_input = new Fl_Input(250,45,100,30, "Threshold ");
302 thres_input->value("");
303 thres_input->callback((Fl_Callback*)set_threshold_cb, this);
305 seq_num_input = new Fl_Input(430,45,100, 30, "Seq Num ");
306 seq_num_input->value("");
307 seq_num_input->callback((Fl_Callback*)set_seq_num_cb, this);
309 // button to launch the analysis
310 test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
311 test->callback((Fl_Callback*)do_analysis_cb, this);
313 // test button to make sure setup data is being stored
314 test = new Fl_Button(w-200,h-30,100,30,"show setup");
315 test->callback((Fl_Callback*)print_cb, this);
317 // generic input, keeping around as template for future additions
318 //_input = new Fl_Input(0, , 30, "");
320 //_input->when(FL_WHEN_ENTER_KEY);
321 //_input->callback((Fl_Callback*)set__cb, this);
329 SetupWindow::~SetupWindow(){}
333 SetupWindow::add_seq_input(int i)
335 Fl_Input *fasta_input, *start_input, *end_input;
336 Fl_Button *seq_browse, *annot_browse;
339 // this remembers what seq index each input is associated with
340 seq_data_instance * something;
341 something = new seq_data_instance;
342 something->sw_ptr = this;
343 something->index = i;
346 // setup sequence file input for text input or file browsing
347 seq_inputs.push_back(new Fl_Input(55, 85+(i*105), w()-165, 30, "seq "));
348 seq_inputs[i]->value("");
349 seq_inputs[i]->callback((Fl_Callback*)seq_file_in_cb, (void*) something);
351 seq_browse = new Fl_Button(w()-105, 85+(i*105), 80, 30, "Browse");
352 seq_browse->callback((Fl_Callback*)choose_seq_file_cb, (void*) something);
354 // setup annotation file input for text input or file browsing
355 annot_inputs.push_back(new Fl_Input(55, 120+(i*105), w()-165, 30, "annot "));
356 annot_inputs[i]->value("");
357 annot_inputs[i]->callback((Fl_Callback*)annot_file_in_cb,(void*)something);
359 annot_browse = new Fl_Button(w()-105, 120+(i*105), 80, 30, "Browse");
360 annot_browse->callback((Fl_Callback*)choose_annot_file_cb, (void*)something);
362 // index of fasta seq wanted if more than 1 seq in file
363 fasta_input = new Fl_Input(90, 155+(i*105), 50, 30, "fasta index");
364 fasta_input->value("");
365 fasta_input->callback((Fl_Callback*)fa_index_in_cb, (void*) something);
367 // subsequence select, index of first bp wanted
368 start_input = new Fl_Input(225, 155+(i*105), 50, 30, "start index");
369 start_input->value("");
370 start_input->callback((Fl_Callback*)sub_start_in_cb, (void*) something);
372 // subsequence select, index of last bp wanted
373 end_input = new Fl_Input(355, 155+(i*105), 50, 30, "end index");
374 end_input->value("");
375 end_input->callback((Fl_Callback*)sub_end_in_cb, (void*) something);
377 seq_scroll->add(seq_inputs[i]);
378 seq_scroll->add(seq_browse);
379 seq_scroll->add(annot_inputs[i]);
380 seq_scroll->add(annot_browse);
381 seq_scroll->add(fasta_input);
382 seq_scroll->add(start_input);
383 seq_scroll->add(end_input);
393 void SetupWindow::print_cb(Fl_Button* o, void* v)
395 SetupWindow* T=(SetupWindow*)v;
396 T->print_cb_real(o,v);
400 void SetupWindow::print_cb_real(Fl_Button* , void*)
402 cout << "ana_name: " << ana_name << endl;
403 cout << "win: " << window << endl;
404 cout << "thres: " << threshold << endl;
405 cout << "seq_num: " << seq_num << endl;
406 //cout << "win_add: " << win_append << end;
407 //cout << "thres_add: " << thres_append << endl;
413 for (i = 0; i < seq_num; i++)
415 cout << seq_files[i] << endl;
416 cout << annot_files[i] << endl;
417 cout << "fasta: " << fasta_indices[i];
418 cout << " start: " << sub_seq_starts[i];
419 cout << " end: " << sub_seq_ends[i] << endl;
420 cout << "blargle!\n";
422 cout << "end of inputs\n" << endl;