Class: Bioroebe::GUI::UniversalWidgets::AntiSenseStrand
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::AntiSenseStrand
show all
- Includes:
- CommandlineArguments, Bioroebe::GUI
- Defined in:
- lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb
Overview
Constant Summary
collapse
- TITLE =
#
TITLE
Specify which title to use for this small widget.
#
'Sense / Anti-Sense Strand'
- WIDTH =
'65% or 500px minimum'
- HEIGHT =
'55% or 300px minimum'
- TEXT_COMPARE_THE_TWO_SEQUENCES =
#
TEXT_COMPARE_THE_TWO_SEQUENCES
#
'_Compare the two sequences'
- MONOSPACED_FONT =
#
MONOSPACED_FONT
When this font is changed, don’t forget to also change the font at SMALLER_FONT.
#
:hack_20
- USE_THIS_FONT =
MONOSPACED_FONT
- MAX_LENGTH =
50_000
- IMG_DNA_HELIX =
'/home/x/data/images/science/biology/DNA_HELIX.jpg'
- SMALLER_FONT =
:hack_16
- USE_THIS_SLIGHTLY_SMALLER_FONT =
#
USE_THIS_SLIGHTLY_SMALLER_FONT
#
:hack_16
- USE_THIS_TITLE_FOR_THE_MAIN_BUTTON =
#
USE_THIS_TITLE_FOR_THE_MAIN_BUTTON
#
'_Determine the DNA sequence'
- PADDING_TO_USE =
12
- DEFAULT_TEXT_FOR_ENTRY1 =
#
DEFAULT_TEXT_FOR_ENTRY1
#
'AGUUCGAUGGAAAATAT'
- DEFAULT_TEXT_FOR_ENTRY2 =
#
DEFAULT_TEXT_FOR_ENTRY2
#
'AGUCCGGUCGAAAAAAA'
ARRAY_ALL_GTK_WIDGETS, FONT_SIZE, OLD_VERBOSE_VALUE, Bioroebe::GUI::USE_THIS_FONT_FAMILY_FOR_GUI_APPLICATIONS
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary
collapse
Instance Method Summary
collapse
#disable_warnings, #enable_warnings, #log_dir?
#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) ⇒ AntiSenseStrand
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 114
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
643
644
645
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 643
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::AntiSenseStrand.run
#
650
651
652
653
654
655
656
657
658
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 650
def self.run(
i = ARGV
)
r = ::Gtk.runner_factory(
::Bioroebe::GUI::Gtk::AntiSenseStrand.new(i)
)
r.modify_background(:normal, :mintcream)
return r
end
|
Instance Method Details
#aminoacid_sequence? ⇒ Boolean
425
426
427
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 425
def aminoacid_sequence?
left_buffer?.to_s
end
|
#border_size? ⇒ Boolean
168
169
170
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 168
def border_size?
8
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag, skeleton tag)
#
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 590
def connect_the_skeleton
abort_on_exception
@top_box.minimal(@label_on_top, 1)
text = left_aligned_text(
"The <b>Hamming distance</b> - a number - measures the number of "\
"\npositions at which two strings of equal length are "\
"different.")
text.make_selectable
text.use_this_font = SMALLER_FONT
@top_box.minimal(text, 12)
@top_box.minimal(@hbox_for_string1, 2)
@top_box.minimal(@hbox_for_string2, 2)
vpaned = mouse_draggable_via_up_and_down_movement(@top_box, @bottom_box)
vpaned.set_size_request(width?, 550)
Thread.new {
sleep 0.01
@entry_n_differences.do_focus
entry1?.deselect
do_compare
}
window = runner_widget(nil, width?, height?, title?)
window << vpaned
::UniversalWidgets.set_main_window(window)
upon_delete_event_quit_the_application
jump_into_the_first_entry
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.set_size_request(80, 100)
window.top_left
run_main
end
|
560
561
562
563
564
565
566
567
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 560
def consider_sanitizing_the_input
@entry_on_top.set_text(@entry_on_top.text.delete('-'))
@entry_on_bottom.set_text(@entry_on_bottom.text.delete('-'))
do_upcase_all_entries
end
|
477
478
479
480
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 477
def consider_sanitizing_the_input_and_then_compare_the_two_sequences
consider_sanitizing_the_input
compare_the_two_sequences
end
|
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 367
def create_buttons
backtrack_button = bold_button(
USE_THIS_TITLE_FOR_THE_MAIN_BUTTON, self, :use_mnemonic
) {
:do_determine_the_backtrack_sequence
}
backtrack_button.set_name('button1')
backtrack_button.do_use_underline
backtrack_button.hint =
"On the <b>left hand side</b>, you should input the "\
"Aminoacid sequence.\n\n"\
"On the <b>right hand side</b>, a possible DNA "\
"sequence for this Aminoacid Sequence will "\
"be displayed.\n\n"\
"Invalid amino acids, such as 'U', will be filtered "\
"out, if given.\n\n"\
"Note that this will not necessarily "\
"generate the same sequence, due to several different codons "\
"encoding for the same aminoacid."
backtrack_button.on_hover_lightblue
@dataset[:backtrack_button] = backtrack_button
a_quit_button = quit_button
a_quit_button.set_name('button1')
a_quit_button.make_bold
@dataset[:quit_button] = a_quit_button
end
|
#
This method will create the button that will compare the two sequences.
#
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 459
def create_compare_button
@compare_button = bold_button(TEXT_COMPARE_THE_TWO_SEQUENCES, self, :use_mnemonics) {
:consider_sanitizing_the_input_and_then_compare_the_two_sequences
}
@compare_button.apply_markup
@compare_button.on_hover(:lightblue)
@compare_button.set_name('button1')
@compare_button.hint = 'Click this button to '\
'<span weight="bold" foreground="lightblue">compare</span> '\
'the two sequences.'
end
|
#create_left_buffer ⇒ Object
308
309
310
311
312
313
314
315
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 308
def create_left_buffer
@dataset[:left_buffer] = create_text_view @dataset[:left_buffer].bblack1
@dataset[:left_buffer].do_wrap_properly
end
|
#create_middle_bar_containing_the_arrow_pointing_to_the_right_side ⇒ Object
#
create_middle_bar_containing_the_arrow_pointing_to_the_right_side
#
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 259
def create_middle_bar_containing_the_arrow_pointing_to_the_right_side
@middle_bar = create_vbox
event_box = create_eventbox(
create_label(:arrow_right)
)
event_box.hint =
'This arrow can be clicked, to convert from the aminoacid sequence '\
'to (one likely) possible DNA sequence.'
event_box.on_clicked {
do_determine_the_backtrack_sequence
}
@middle_bar.minimal(
event_box
)
end
|
#create_right_buffer ⇒ Object
149
150
151
152
153
154
155
156
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 149
def create_right_buffer
@dataset[:right_buffer] = create_text_view @dataset[:right_buffer].bblack1
@dataset[:right_buffer].do_wrap_properly
end
|
#create_the_entries ⇒ Object
#
create_the_entries (entries tag, entry tag)
#
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 196
def create_the_entries
@entry_n_differences = entry_with_icon_name('edit-undo-symbolic-rtl.symbolic')
@entry_n_differences.xalign = 0.5 @entry_n_differences.bblack1
@entry_n_differences.clear_background
@entry_n_differences.yellow_background
@entry_on_top = create_entry(DEFAULT_TEXT_FOR_ENTRY1)
@entry_on_top.set_font(MONOSPACED_FONT)
@entry_on_top.clear_background
@entry_on_top.css_class('BG_lightsteelblue')
@entry_on_top.bblack1
@entry_on_top.on_changed { do_calculate_the_differences }
@entry_on_top.hint = 'This entry should contain the first sequence (seq1).'
@entry_on_top.set_max_length(50_000)
@entry_on_top.on_key_press_event { |widget, event|
old_text = widget.text
keyname = Gdk::Keyval.to_name(event.keyval)
case keyname.upcase
when *%w( A T C G U )
when *%w( B D E F H I J K L M N O P Q R S V W X Y Z ) unless event.state.control_mask? widget.set_text(old_text.upcase)
end
end
} if false @entry_on_top.on_key_release { |widget, event|
old_text = @entry_on_top.text
new_text = @entry_on_top.text.upcase
unless old_text == new_text
@entry_on_top.set_text(new_text)
@entry_on_top.move_cursor_to_the_most_right_position
end
}
@entry_on_bottom = create_entry(DEFAULT_TEXT_FOR_ENTRY2)
@entry_on_bottom.set_font(MONOSPACED_FONT)
@entry_on_bottom.css_classes('clear_background BG_lightsteelblue')
@entry_on_bottom.bblack1
@entry_on_bottom.on_changed { do_calculate_the_differences }
@entry_on_bottom.hint = 'This entry should contain the second sequence (seq2).'
@entry_on_bottom.set_max_length(50_000)
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 485
def create_the_skeleton
create_the_entries
@top_box = vbox
@label_on_top = bold_label(TITLE)
@label_on_top.hint =
"Only <b>valid nucleotides</b> (A, T, C, G, U) \n"\
"can be accepted as input."
@hbox_for_string1 = create_hbox
@hbox_for_string1.minimal(text('1').make_bold, 1)
@hbox_for_string1.maximal(@entry_on_top, 1)
@hbox_for_string2 = create_hbox
@hbox_for_string2.minimal(text('2').make_bold, 1)
@hbox_for_string2.maximal(@entry_on_bottom, 1)
create_compare_button
small_hbox = create_hbox
short_text_widget = text('<b>n differences</b> found:')
short_text_widget.do_markify
small_hbox.minimal(short_text_widget, 2)
small_hbox.hint =
'This entry will show <b>how many differences</b> '\
'exist between these two strings.'
small_hbox.minimal(@entry_n_differences, 2)
@bottom_box = create_vbox
@bottom_box.pack_start(@compare_button, expand: false, fill: false, padding: 1)
@bottom_box.pack_start(small_hbox, expand: false, fill: true, padding: 0)
end
|
#create_top_hbox ⇒ Object
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 278
def create_top_hbox
scrolled_window_right = scrolled_window(right_buffer?)
scrolled_window_right.clear_background
scrolled_window_right.width_height(300, 300)
scrolled_window_right.bblack1
scrolled_window_right.mar2px
scrolled_window_left = scrolled_window(left_buffer?)
scrolled_window_left.clear_background
scrolled_window_left.width_height(300, 300)
scrolled_window_left.bblack1
scrolled_window_left.mar2px
top_hpaned = gtk_hpaned(
scrolled_window_left,
scrolled_window_right
) {{ border_width: 10 }}
this_position = (width?.to_f / 1.5).to_i
top_hpaned.set_position(this_position)
top_hpaned.show_all
@dataset[:top_hbox] = top_hpaned
end
|
#do_determine_the_backtrack_sequence ⇒ Object
Also known as:
do_determine_the_DNA_sequence
#
do_determine_the_backtrack_sequence (click tag)
This will do what is necessary to find the backtrack sequence.
#
441
442
443
444
445
446
447
448
449
450
451
452
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 441
def do_determine_the_backtrack_sequence
filter_away_invalid_aminoacids_from_the_left_buffer
_ = left_buffer?.text?.to_s
_.upcase!
_ = ::Bioroebe.remove_invalid_aminoacids(_)
left_buffer?.set_text(_)
text_for_right_hand_side = ::Bioroebe::ProteinToDNA.new(_, :be_quiet).dna_sequence?
right_buffer?.set_text(text_for_right_hand_side)
end
|
#do_upcase_all_entries ⇒ Object
#
do_upcase_all_entries
#
548
549
550
551
552
553
554
555
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 548
def do_upcase_all_entries
[
@entry_on_top,
@entry_on_bottom
].each {|entry|
entry.do_upcase
}
end
|
#entry1? ⇒ Boolean
Also known as:
entry1
189
190
191
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 189
def entry1?
@entry_on_top
end
|
#filter_away_invalid_aminoacids_from_the_left_buffer ⇒ Object
#
filter_away_invalid_aminoacids_from_the_left_buffer
This method is used to “sanitize” the input - invalid aminoacids are flat out removed.
#
400
401
402
403
404
405
406
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 400
def filter_away_invalid_aminoacids_from_the_left_buffer
_ = left_buffer?.text?.to_s
possible_new_text = Bioroebe.strict_filter_away_invalid_aminoacids(_)
unless _ == possible_new_text
left_buffer?.set_text(possible_new_text)
end
end
|
#handle_CSS_rules ⇒ Object
Also known as:
handle_CSS
#
handle_CSS_rules (CSS tag, css tag)
#
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 334
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
add_these_custom_CSS_rules '
#custom_treeview.view header button {
background-color: white;
color: royalblue;
font-weight: bold;
font-size: larger;
padding: 8px;
}'
apply_the_CSS_rules
end
|
#jump_into_the_first_entry ⇒ Object
#
jump_into_the_first_entry
#
636
637
638
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 636
def jump_into_the_first_entry
entry1?.do_focus
end
|
#left_buffer? ⇒ Boolean
Also known as:
left?
432
433
434
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 432
def left_buffer?
@dataset[:left_buffer]
end
|
#main_font? ⇒ Boolean
320
321
322
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 320
def main_font?
USE_THIS_FONT
end
|
352
353
354
355
356
357
358
359
360
361
362
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 352
def (i = nil)
if i
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when ''
end
end
end
end
|
#padding? ⇒ Boolean
161
162
163
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 161
def padding?
PADDING_TO_USE
end
|
#reset ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 129
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?
set_border_width(5)
end
|
#right_buffer? ⇒ Boolean
Also known as:
right?
411
412
413
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 411
def right_buffer?
@dataset[:right_buffer]
end
|
#run ⇒ Object
534
535
536
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 534
def run
run_super
end
|
#seq1? ⇒ Boolean
175
176
177
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 175
def seq1?
@entry_on_top.text
end
|
#seq2? ⇒ Boolean
182
183
184
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 182
def seq2?
@entry_on_bottom.text
end
|
#set_aminoacid_sequence(i) ⇒ Object
#
set_aminoacid_sequence
#
418
419
420
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 418
def set_aminoacid_sequence(i)
@dataset[:left_buffer].set_text(i.to_s)
end
|
#slightly_smaller_font? ⇒ Boolean
#
slightly_smaller_font?
#
327
328
329
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 327
def slightly_smaller_font?
USE_THIS_SLIGHTLY_SMALLER_FONT
end
|
#synchronize_anti_sense ⇒ Object
#
synchronize_anti_sense
Will fetch content and synchronize the @entry_anti_sense
#
574
575
576
577
578
579
580
581
582
583
584
585
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 574
def synchronize_anti_sense
this_text = ''.dup
@entry_sense.text?.each_char { |char|
case char
when 'A' then this_text << 'T'
when 'T' then this_text << 'A'
when 'C' then this_text << 'G'
when 'G' then this_text << 'C'
end
}
@entry_anti_sense.set_text(this_text)
end
|
#top_hbox? ⇒ Boolean
541
542
543
|
# File 'lib/bioroebe/gui/universal_widgets/anti_sense_strand/anti_sense_strand.rb', line 541
def top_hbox?
@dataset[:top_hbox]
end
|