Class: Bioroebe::GUI::UniversalWidgets::Alignment
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::Alignment
show all
- Includes:
- CommandlineArguments
- Defined in:
- lib/bioroebe/gui/universal_widgets/alignment/alignment.rb
Overview
Constant Summary
collapse
- TITLE =
'Alignment'
- WIDTH =
'65% or 500px minimum'
- HEIGHT =
'55% or 300px minimum'
- USE_THIS_FONT =
:hack_26
- FONT_FOR_THE_ENTRIES =
#
FONT_FOR_THE_ENTRIES
The entries must use a mono-spaced font.
#
:hack_22
- TEXT_INPUT_THE_SEQUENCES =
#
TEXT_INPUT_THE_SEQUENCES
#
'Input the sequences that you wish '\
'to compare to one another'
- TOOLTIP_HINT_FOR_THE_DO_ANALYSE_BUTTON =
"Click on this button to analyse the given sequence. Make sure "\
"to use <b>newlines</b> in order to split the sequence at hand."
- TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE =
#
TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE
This is the base-tooltip for the entry that retains our consensus sequence.
#
'This entry will contain the <b>consensus sequence</b>, '\
'derived from the above sequences.'
- TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE_TRAILING_INFORMATION =
#
TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE_TRAILING_INFORMATION
#
"\n\nTake note that in the event that there is <b>an even number of "\
"input sequences</b>, the entries defined before will take precedence. "\
"So, for instance, if you have four sequences in total, where two are "\
"ATTA and the next two are ATTT, then the consensus sequence is "\
"currently assumed to be <b>ATTA</b>."
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary
collapse
Instance Method Summary
collapse
#commandline_arguments?, #commandline_arguments_that_are_files?, #e, #first?, #first_non_hyphen_argument?, #remove_hyphens_from_the_commandline_arguments, #return_commandline_arguments_as_string, #return_commandline_arguments_that_are_not_files, #return_entries_without_two_leading_hyphens, #select_commandline_arguments, #select_entries_starting_with_two_hyphens, #set_commandline_arguments
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_will_we_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ Alignment
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 95
def initialize(
commandline_arguments = nil,
run_already = true
)
determine_the_GUI_to_be_used(commandline_arguments)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
502
503
504
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 502
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::Alignment.run
#
509
510
511
512
513
514
515
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 509
def self.run(
i = ARGV
)
::Gtk.gtk_runner_factory(
::Bioroebe::GUI::Gtk::Alignment.new(i)
)
end
|
Instance Method Details
#alignment? ⇒ Boolean
478
479
480
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 478
def alignment?
@alignment
end
|
#border_size? ⇒ Boolean
222
223
224
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 222
def border_size?
8
end
|
278
279
280
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 278
def button_convert?
@button_convert
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag, skeleton tag)
#
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 520
def connect_the_skeleton
abort_on_exception
grid = default_grid
grid.full_row(return_the_first_row)
grid.full_row(@scrolled_window)
grid.full_row(@entry_consensus_sequence)
grid.full_row(@entry_numbers)
grid.full_row(@button_do_analyse)
grid.hcenter
window = runner_widget(nil, width?, height?, title?)
window << grid
do_focus_on_the_textview
::UniversalWidgets.set_main_window(window)
upon_delete_event_quit_the_application
window.use_this_font = font?
window.show_all
window.set_size_request(width?, height?)
window.set_default_size(width?, height?)
window.set_padding(padding?)
window.set_border_size(border_size?)
window.top_left
run_main
end
|
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 286
def create_the_buttons
@button_do_analyse = bold_button('_Do analyse', self, :use_mnemonic) {
:the_do_analyse_button_was_clicked
}
@button_do_analyse.clear_background
@button_do_analyse.bblack1
@button_do_analyse.on_hover(:lightblue)
@button_do_analyse.hint = TOOLTIP_HINT_FOR_THE_DO_ANALYSE_BUTTON
end
|
#create_the_checkboxes ⇒ Object
#
create_the_checkboxes
#
266
267
268
269
270
271
272
273
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 266
def create_the_checkboxes
@checkbox1 = create_checkbox
@checkbox1.is_active
@checkbox2 = create_checkbox
end
|
#create_the_consensus_sequence_entry ⇒ Object
#
create_the_consensus_sequence_entry
#
#create_the_entries ⇒ Object
#
create_the_entries (entry tag, entries tag)
#
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 164
def create_the_entries
create_the_consensus_sequence_entry
@entry_numbers = create_entry
@entry_numbers.bblack1
@entry_numbers.use_this_font = FONT_FOR_THE_ENTRIES
@entry_numbers.hint =
'This area may indicate the numbers for '\
'the alignment shown right above.'
@entry_numbers.very_light_yellow_background
end
|
202
203
204
205
206
207
208
209
210
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 202
def create_the_scrolled_window
@scrolled_window = create_scrolled_window(@text_view)
@scrolled_window.width_height(300, 400)
@scrolled_window.pad4px
@scrolled_window.bblack2
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
255
256
257
258
259
260
261
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 255
def create_the_skeleton
create_the_checkboxes create_the_entries
create_the_buttons
create_the_text_buffer_and_the_text_view
create_the_scrolled_window
end
|
#create_the_text_buffer_and_the_text_view ⇒ Object
#
create_the_text_buffer_and_the_text_view
#
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 181
def create_the_text_buffer_and_the_text_view
@text_buffer = create_text_buffer
@text_view = create_text_view(@text_buffer)
end
|
#do_analyse(_ = text_buffer?.text?) ⇒ Object
Also known as:
do_analyse_again
#
do_analyse
This method will be called whenever the user hits the “Do analyse” button.
#
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 361
def do_analyse(
_ = text_buffer?.text?
)
if _ and !_.empty?
_.strip!
alignment?.use_this_as_input(_)
consensus_sequence = return_the_consensus_sequence
@entry_consensus_sequence.set_text(consensus_sequence)
else
pop_up_widget(
over_this_widget: text_view_widget?,
text: 'Please assign a sequence first.'
)
end
end
|
#do_focus_on_the_textview ⇒ Object
#
do_focus_on_the_textview
#
549
550
551
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 549
def do_focus_on_the_textview
textview?.do_focus
end
|
#do_open_and_assign_a_local_file ⇒ Object
#
do_open_and_assign_a_local_file
#
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 447
def do_open_and_assign_a_local_file
open_local_file {{
start_directory: log_dir?,
additional_folders: [
log_dir?,
'/Depot/j/',
'/Depot/jj/',
'/Depot/jjj/',
'/Depot/jjjj/'
]
}}
_ = main_file?
if _ and File.exist?(_)
dataset = File.read(_)
@text_buffer.set_text(dataset)
do_analyse_again
end
end
|
#do_trigger_the_conversion(i = @entry1.text?, checkbox1 = @checkbox1) ⇒ Object
Also known as:
do_the_conversion
#
do_trigger_the_conversion (conversion tag)
This method is the one that will convert from the three-letter to the one-letter and vice versa.
#
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 305
def do_trigger_the_conversion(
i = @entry1.text?,
checkbox1 = @checkbox1
)
i = i.to_s.dup.delete(' ')
if checkbox1.active?
new_result = Bioroebe.three_to_one(i).to_s
else
new_result = Bioroebe.one_to_three(i).to_s
end
if new_result and !new_result.empty?
@entry2.set_text(new_result)
@entry2.make_bold
end
end
|
#entry_consensus_sequence? ⇒ Boolean
#
entry_consensus_sequence?
#
428
429
430
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 428
def entry_consensus_sequence?
@entry_consensus_sequence
end
|
#handle_CSS_rules ⇒ Object
Also known as:
handle_CSS
#
handle_CSS_rules (CSS tag)
#
130
131
132
133
134
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 130
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
apply_the_CSS_rules
end
|
#padding? ⇒ Boolean
215
216
217
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 215
def padding?
12
end
|
#realign_the_numbers_showing_how_long_the_consensus_sequence_is ⇒ Object
#
realign_the_numbers_showing_how_long_the_consensus_sequence_is
#
401
402
403
404
405
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 401
def realign_the_numbers_showing_how_long_the_consensus_sequence_is
@entry_numbers.center if @entry_numbers.respond_to?(:center)
n_characters = @entry_consensus_sequence.text?.size
@entry_numbers.set_text(return_fill_up_to(n_characters))
end
|
#reset ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 110
def reset
super() if respond_to?(:super)
reset_the_internal_variables
reset_the_base_module infer_the_namespace
@configuration = [true, __dir__, namespace?]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
handle_CSS if use_gtk3?
reset_the_alignment_object
end
|
#reset_the_alignment_object ⇒ Object
#
reset_the_alignment_object
#
492
493
494
495
496
497
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 492
def reset_the_alignment_object
@alignment = Bioroebe::Alignment.new(nil, :do_not_run_yet)
end
|
#return_fill_up_to(i) ⇒ Object
435
436
437
438
439
440
441
442
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 435
def return_fill_up_to(i)
_ = ''.dup
i.times {|counter|
counter = (counter+1) % 10
_ << counter.to_s
}
return _
end
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 324
def return_the_checkbox_widget
smaller_font = smaller_font?
grid = default_grid
text1 = text('3-to-1 conversion')
text1.use_this_font(smaller_font)
text1.hint = 'Convert the three letter code to the one letter code.'
pp text1
grid.left(text1)
grid.right(@checkbox1)
text2 = text('1-to-3 conversion')
text2.use_this_font(smaller_font)
text2.hint = 'Convert the one letter code to the three letter code.'
grid.left(text2)
grid.right(@checkbox2)
@checkbox1.on_toggled {
if @checkbox1.active? == false
@checkbox2.is_now_active
else
@checkbox2.is_now_inactive
end
}
@checkbox2.on_toggled {
if @checkbox2.active? == false
@checkbox1.is_now_active
else
@checkbox1.is_now_inactive
end
}
return grid
end
|
#return_the_consensus_sequence ⇒ Object
#
return_the_consensus_sequence
#
387
388
389
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 387
def return_the_consensus_sequence
@alignment.consensus_sequence?
end
|
#return_the_first_row ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 139
def return_the_first_row
_ = create_hbox
top_label = left_aligned_label(
TEXT_INPUT_THE_SEQUENCES
)
top_label.make_selectable
top_label.center
_.minimal(top_label)
use_this_image = image_document_open
if use_this_image
event_box = event_box(use_this_image)
if event_box
event_box.hint = 'Click on this icon to open a local file.'
event_box.on_clicked {
do_open_and_assign_a_local_file
}
_.pack_end(event_box)
end
end
return _
end
|
#run ⇒ Object
380
381
382
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 380
def run
run_super
end
|
#smaller_font? ⇒ Boolean
229
230
231
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 229
def smaller_font?
SMALLER_FONT
end
|
#text_buffer? ⇒ Boolean
485
486
487
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 485
def text_buffer?
@text_buffer
end
|
#text_view_widget? ⇒ Boolean
394
395
396
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 394
def text_view_widget?
@text_view
end
|
#textview? ⇒ Boolean
195
196
197
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 195
def textview?
@text_view
end
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 236
def the_do_analyse_button_was_clicked
do_analyse
realign_the_numbers_showing_how_long_the_consensus_sequence_is
update_the_hint_for_the_entry_consequences_sequence(
(
"This entry will contain the consensus sequence, "\
"derived from the above "+
(@text_buffer.text?.count("\n")+1).to_s+" sequences.\n\nNote "\
"that only the minimal length will be compared - "\
"superfluous nucleotides will NOT be considered unless "\
"they can be aligned to other sequences."+
TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE_TRAILING_INFORMATION
).squeeze(' ')
)
end
|
#update_the_hint_for_the_entry_consequences_sequence(i = '') ⇒ Object
#
update_the_hint_for_the_entry_consequences_sequence
#
469
470
471
472
473
|
# File 'lib/bioroebe/gui/universal_widgets/alignment/alignment.rb', line 469
def update_the_hint_for_the_entry_consequences_sequence(
i = ''
)
@entry_consensus_sequence.hint = i
end
|