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_subana.hh"
15 do_subana_cb(Fl_Button* o, void* v)
17 SubanaWindow* T=(SubanaWindow*)v;
22 // passes the parameters to the mussa class object and orders it to run
24 SubanaWindow::real_do_subana()
27 string a_sequence, err_msg;
29 // <-- need a check here to make sure all vars have a valid value
32 an_analysis->set_name(ana_name);
33 an_analysis->set_seq_num(seq_num);
34 an_analysis->set_window(window);
35 an_analysis->set_threshold(threshold);
37 for(i=0; i < seq_num; i++)
39 a_sequence = the_Seqs[i].seq();
40 cout << a_sequence.length() << endl;
41 a_sequence = a_sequence.substr(sub_seq_starts[i],
42 sub_seq_ends[i] - sub_seq_starts[i] );
43 cout << a_sequence.length() << endl;
44 an_analysis->add_a_seq(a_sequence);
47 err_msg = an_analysis->analyze(0,0, 't', 0.0);
49 cout << "Feel the tribal beat\n";
52 //fl_alert(err_msg.c_str());
63 // *** subsequence start select
66 sub_start_in_cb1(Fl_Input* o, void* v)
68 sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
69 SubanaWindow* T= blah->sw_ptr;
70 T->real_sub_start_in_cb(o,blah->index);
74 SubanaWindow::real_sub_start_in_cb(Fl_Input* o, int i)
76 sub_seq_starts[i] = atoi(o->value());
79 // *** subsequence end select
82 sub_end_in_cb1(Fl_Input* o, void* v)
84 sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
85 SubanaWindow* T= blah->sw_ptr;
86 T->real_sub_end_in_cb(o,blah->index);
90 SubanaWindow::real_sub_end_in_cb(Fl_Input* o, int i)
92 sub_seq_ends[i] = atoi(o->value());
96 // *** input analysis name
99 set_ana_name_cb1(Fl_Input* o, void* v)
101 SubanaWindow* T=(SubanaWindow*)v;
102 T->real_set_ana_name_cb(o);
106 SubanaWindow::real_set_ana_name_cb(Fl_Input* o)
108 ana_name = o->value();
111 // *** input window size
114 set_win_size_cb1(Fl_Input* o, void* v)
116 SubanaWindow* T=(SubanaWindow*)v;
117 T->real_set_win_size_cb(o);
121 SubanaWindow::real_set_win_size_cb(Fl_Input* o)
123 window = atoi(o->value());
126 // *** input threshold
129 set_threshold_cb1(Fl_Input* o, void* v)
131 SubanaWindow* T=(SubanaWindow*)v;
132 T->real_set_threshold_cb(o);
136 SubanaWindow::real_set_threshold_cb(Fl_Input* o)
138 threshold = atoi(o->value());
149 SubanaWindow::SubanaWindow(int w, int h, const char* title,Mussa *the_analysis,
150 vector<Sequence> some_Seqs):Fl_Window(w,h,title)
156 an_analysis = the_analysis;
157 the_Seqs = some_Seqs;
160 // initialize parameters
167 name_input = new Fl_Input(135, 10, w-140, 30, "SubAnalysis Name ");
168 name_input->value("");
169 //name_input->when(FL_WHEN_ENTER_KEY);
170 name_input->box(FL_BORDER_BOX);
171 name_input->callback((Fl_Callback*)set_ana_name_cb1, this);
173 // add in radio buttons for win_append and thres_append eventually
177 win_input = new Fl_Input(135,45,100,30, "Window: ");
178 win_input->value("");
179 win_input->callback((Fl_Callback*)set_win_size_cb1, this);
181 thres_input = new Fl_Input(320,45,100,30, "Threshold: ");
182 thres_input->value("");
183 thres_input->callback((Fl_Callback*)set_threshold_cb1, this);
185 // button to launch the analysis
186 test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
187 test->callback((Fl_Callback*)do_subana_cb, this);
189 // test button to make sure setup data is being stored
190 test = new Fl_Button(w-200,h-30,100,30,"show setup");
191 test->callback((Fl_Callback*)print_cb, this);
193 // add all the inputs for the sub sequence starts & ends
196 seq_num = the_Seqs.size();
198 seq_scroll = new Fl_Scroll(5,80,w-10,h-115);
199 seq_scroll->color(FL_WHITE);
201 for (i = 0; i < seq_num; i++)
203 sub_seq_starts.push_back(0);
204 sub_seq_ends.push_back(0);
205 a_name = the_Seqs[i].sp_name();
206 cout << a_name << endl;
207 add_seq_input(i, a_name);
209 seq_scroll->box(FL_DOWN_FRAME);
219 SubanaWindow::~SubanaWindow(){}
223 SubanaWindow::add_seq_input(int i, string a_name)
225 Fl_Input *start_input, *end_input;
228 // this remembers what seq index each input is associated with
229 sub_seq_data_instance * something;
230 something = new sub_seq_data_instance;
231 something->sw_ptr = this;
232 something->index = i;
235 // subsequence select, index of first bp wanted
236 start_input = new Fl_Input(150, 85+(i*35), 70, 30, "start index: ");
237 start_input->value("");
238 start_input->callback((Fl_Callback*)sub_start_in_cb1, (void*) something);
240 // subsequence select, index of last bp wanted
241 end_input = new Fl_Input(300, 85+(i*35), 70, 30, "end index: ");
242 end_input->value("");
243 end_input->callback((Fl_Callback*)sub_end_in_cb1, (void*) something);
245 seq_scroll->add(start_input);
246 seq_scroll->add(end_input);
256 void SubanaWindow::print_cb(Fl_Button* o, void* v)
258 SubanaWindow* T=(SubanaWindow*)v;
259 T->print_cb_real(o,v);
263 void SubanaWindow::print_cb_real(Fl_Button* , void*)
265 cout << "ana_name: " << ana_name << endl;
266 cout << "win: " << window << endl;
267 cout << "thres: " << threshold << endl;
268 cout << "seq_num: " << seq_num << endl;
269 //cout << "win_add: " << win_append << end;
270 //cout << "thres_add: " << thres_append << endl;
276 for (i = 0; i < seq_num; i++)
278 //cout << seq_files[i] << endl;
279 //cout << annot_files[i] << endl;
280 //cout << "fasta: " << fasta_indices[i];
281 cout << " start: " << sub_seq_starts[i];
282 cout << " end: " << sub_seq_ends[i] << endl;
283 cout << "blargle!\n";
285 cout << "end of inputs\n" << endl;