Class: Bioroebe::GUI::UniversalWidgets::RandomSequence
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::RandomSequence
show all
- Includes:
- CommandlineArguments, Bioroebe::GUI
- Defined in:
- lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb
Overview
Constant Summary
collapse
- TITLE =
#
TITLE
Specify which title to use for this widget.
#
'Random Sequence - for DNA, RNA and aminoacids'
- WIDTH =
'75% or 1200px minimum'
- HEIGHT =
'55% or 980px minimum'
- FONT_LARGE =
'Calibri 32'
- MONOSPACED_FONT =
#
MONOSPACED_FONT
When this font is changed, don’t forget to also change the font at SMALLER_FONT.
#
:hack_22
- USE_THIS_FONT =
MONOSPACED_FONT
- USE_THIS_MONOFONT =
MONOSPACED_FONT
- SMALLER_FONT =
:hack_16
- USE_THIS_SLIGHTLY_SMALLER_FONT =
#
USE_THIS_SLIGHTLY_SMALLER_FONT
#
:hack_16
['one-letter abbreviation', 'n times']
- GENERATE_N_AMINOACIDS_BY_DEFAULT =
#
GENERATE_N_AMINOACIDS_BY_DEFAULT
#
15
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) ⇒ RandomSequence
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 91
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
609
610
611
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 609
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::RandomSequence.run
#
616
617
618
619
620
621
622
623
624
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 616
def self.run(
i = ARGV
)
r = ::Gtk.runner_factory(
::Bioroebe::GUI::Gtk::RandomSequence.new(i)
)
r.background_colour(:white)
return r
end
|
Instance Method Details
#aminoacid_sequence? ⇒ Boolean
Also known as:
sequence?, main_sequence?
523
524
525
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 523
def aminoacid_sequence?
@entry_containing_the_sequence.text?.to_s
end
|
#border_size? ⇒ Boolean
136
137
138
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 136
def border_size?
4
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag, skeleton tag)
#
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 576
def connect_the_skeleton
abort_on_exception
vbox1 = create_vbox
vbox1.minimal(@top_bar, 3)
vbox1.minimal(@entry_containing_the_sequence, 3)
vbox1.minimal(@button_for_generating_a_new_random_sequence, 3)
vbox1.minimal(@entry_for_n_entries_in_the_sequence, 3)
hbox_for_the_button_copy_to_clipboard = create_hbox
hbox_for_the_button_copy_to_clipboard.minimal(@button_copy_to_clipboard)
hbox_for_the_button_copy_to_clipboard.align_into_the_center
vbox1.minimal(hbox_for_the_button_copy_to_clipboard, 3)
vbox1.minimal(@statistical_widget_top_panel, 0)
vbox1.maximal(@statistical_widget, 3)
window = runner_widget(nil, width?, height?, title?)
window << vbox1
::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
|
#
This method will fill up the “table”.
#
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 465
def create_statistical_information
create_statistical_top_panel
@statistical_widget = create_vbox
array1 = ::Bioroebe.return_array_of_common_aminoacids
array2 = Array.new(array1.size, '0')
array = array1.zip(array2) array.prepend(USE_THIS_HEADER)
@tree_view, @list_store = tree_widget_with_two_columns_per_row(array)
do_properly_setup_the_tree_view
scrolled_window = create_scrolled_window(@tree_view)
scrolled_window.set_border_width(10)
scrolled_window.bblack1
@statistical_widget.maximal(scrolled_window, 5)
hbox1 = create_hbox
hbox1.minimal(@clear_button)
hbox1.align_into_the_center
@statistical_widget.minimal(hbox1, 2)
enable_proper_sorting_for_the_list_store
on_right_click_in_the_tree_view_deselect_the_selection
end
|
#create_statistical_top_panel ⇒ Object
#
create_statistical_top_panel
#
283
284
285
286
287
288
289
290
291
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 283
def create_statistical_top_panel
@statistical_widget_top_panel = bold_label(
'Showing statistical information about the '\
'assigned aminoacid sequence next'
)
end
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 248
def create_the_buttons
@clear_button = bold_button('_Clear the table above', self, :use_mnemonics) {
:do_clear_the_list_store
}
@clear_button.hint = 'Clear the above dataset / table'
@clear_button.set_name('button1')
@button_for_generating_a_new_random_sequence = bold_button(
'_Generate a random aminoacid sequence',
self,
:use_mnemonics
) {{ tooltip: 'Clicking on this button will <b>generate a random '\
'aminoacid sequence</b>. Do not set a too high value '\
'as that may take a long time, and consume a '\
'lot of memory/RAM.'
}}
@button_for_generating_a_new_random_sequence.on_click_event {
do_generate_a_random_sequence(n_aminoacids?)
}
@button_for_generating_a_new_random_sequence.set_name('button1')
create_the_copy_to_clipboard_button
end
|
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 168
def create_the_copy_to_clipboard_button
@button_copy_to_clipboard = bold_button('_Copy to the xorg-clipboard',
self, :use_mnemonic) {
:do_copy_to_the_clipboard
}
@button_copy_to_clipboard.hint = 'This will <b>copy the aminoacid '\
'sequence</b> to the <b>xorg-clipboard</b>.'
@button_copy_to_clipboard.set_name('button1')
end
|
#create_the_entries ⇒ Object
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 435
def create_the_entries
@entry_containing_the_sequence = create_entry
@entry_containing_the_sequence.on_click_select_everything
@entry_containing_the_sequence.yellow_background
@entry_containing_the_sequence.bblack1
@entry_for_n_entries_in_the_sequence = create_entry { :align_center }
@entry_for_n_entries_in_the_sequence.set_text(GENERATE_N_AMINOACIDS_BY_DEFAULT.to_s)
@entry_for_n_entries_in_the_sequence.yellow_background
@entry_for_n_entries_in_the_sequence.on_click_select_everything
@entry_for_n_entries_in_the_sequence.bblack1
@entry_for_n_entries_in_the_sequence.on_enter {
do_generate_a_random_sequence_using_the_value_from_the_proper_entry
}
@entry_for_n_entries_in_the_sequence.hint = 'Input here how many random '\
'amino acids should be generated.'
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
238
239
240
241
242
243
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 238
def create_the_skeleton
create_the_buttons create_statistical_information create_the_top_bar
create_the_entries
end
|
#create_the_top_bar ⇒ Object
317
318
319
320
321
322
323
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 317
def create_the_top_bar
@top_bar = gtk_top_bar
button_open_file = button('_Open File', self, :use_mnemonics) {
:do_open_a_file_and_then_set_the_correct_values
}
button_open_file.hint = 'Click on this button to open a local FASTA '\
'file.'
button_open_file.bblack1
@top_bar.add(button_open_file)
@combo_box_for_the_sequence_type = combo_box_entry(
%w( aminoacid DNA RNA )
)
@combo_box_for_the_sequence_type.first_is_active
@combo_box_for_the_sequence_type.on_changed {
_ = @combo_box_for_the_sequence_type.text?
@button_for_generating_a_new_random_sequence.set_text(
"Generate a random #{_} sequence"
)
@button_for_generating_a_new_random_sequence.make_bold
@statistical_widget_top_panel.set_text(
"Showing statistical information about the "\
"assigned #{_} sequence next"
)
@statistical_widget_top_panel.make_bold
@tree_view.model = nil
@list_store = nil
@list_store = gtk_list_store(String, String)
case mode?
when 'DNA','RNA'
if mode? == 'DNA'
array1 = %w( A T C G )
else
array1 = %w( A U C G )
end
array2 = Array.new(array1.size, '0')
zipped = array1.zip(array2) zipped.each {|a, b|
iter = @list_store.append
iter.set_value(0, a)
iter.set_value(1, b)
}
else end
@tree_view.model = @list_store
}
@top_bar.add(@combo_box_for_the_sequence_type)
end
|
#do_clear_the_list_store ⇒ Object
#
do_clear_the_list_store
#
296
297
298
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 296
def do_clear_the_list_store
@list_store.clear
end
|
#do_copy_to_the_clipboard ⇒ Object
#
do_copy_to_the_clipboard
#
414
415
416
417
418
419
420
421
422
423
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 414
def do_copy_to_the_clipboard
begin
require 'xorg_buffer'
rescue LoadError; end
if Object.const_defined? :XorgBuffer
XorgBuffer.copy_this_text_to_the_clipboard(aminoacid_sequence?)
else
e 'The gem xorg_buffer is not installed, or could not be found.'
end
end
|
#do_evaluate_the_sequence(use_this_sequence = main_sequence?
) ⇒ Object
#
do_evaluate_the_sequence
#
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 374
def do_evaluate_the_sequence(
use_this_sequence = main_sequence?
)
do_clear_the_list_store
case mode?
when 'DNA','RNA'
@tree_view.remove_the_columns
column1 = ::Gtk::TreeViewColumn.new('DNA-Nucleotide', gtk_cell_renderer_text, { text: 0 })
column2 = ::Gtk::TreeViewColumn.new('n times', gtk_cell_renderer_text, { text: 1 })
@tree_view.append_column(column1)
@tree_view.append_column(column2)
@tree_view.is_sortable
if mode? == 'DNA'
array1 = %w( A T C G )
else
array1 = %w( A U C G )
end
array2 = Array.new(array1.size, '0')
array2 = Bioroebe.return_DNA_composition_hash(use_this_sequence).values.map(&:to_s)
array = array1.zip(array2)
when 'aminoacids'
array1 = ::Bioroebe.return_array_of_common_aminoacids
array2 = Bioroebe::CountAmountOfAminoacids.return_composition_hash(use_this_sequence).values.map(&:to_s)
array = array1.zip(array2) end
::Gtk.populate_this_liststore(@list_store, array)
end
|
#do_generate_a_random_sequence(n_aminoacids = :default) ⇒ Object
#
do_generate_a_random_sequence
This is the method that will be run whenever a new random aminoacid sequence is to be generated.
#
187
188
189
190
191
192
193
194
195
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
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 187
def do_generate_a_random_sequence(
n_aminoacids = :default
)
case n_aminoacids
when nil, :default
n_aminoacids = GENERATE_N_AMINOACIDS_BY_DEFAULT
end
n_aminoacids = n_aminoacids.to_s
case mode?
when /RNA/i,
/DNA/i
use_this_as_the_new_sequence = :: Bioroebe.generate_random_dna_sequence(n_aminoacids).to_s
array1 = Bioroebe::DNA_NUCLEOTIDES
if mode?.to_s == 'RNA'
use_this_as_the_new_sequence = ::Bioroebe.generate_random_rna_sequence(n_aminoacids).to_s
array1 = Bioroebe::RNA_NUCLEOTIDES
end
hash = {}
array1.each {|this_key|
hash[this_key] = 0
}
use_this_as_the_new_sequence.chars.each {|this_nucleotide|
hash[this_nucleotide.to_s] += 1
}
array2 = hash.values.map {|entry| entry.to_s }
else use_this_as_the_new_sequence = ::Bioroebe.create_random_aminoacids(n_aminoacids).to_s
array1 = ::Bioroebe.return_array_of_common_aminoacids
array2 = Bioroebe::CountAmountOfAminoacids.return_composition_hash(use_this_as_the_new_sequence).values.map(&:to_s)
end
@entry_containing_the_sequence.set_content(use_this_as_the_new_sequence)
array = array1.zip(array2) array = array.sort_by {|a, b| b }.reverse ::Gtk.populate_this_liststore(@list_store, array)
end
|
#do_generate_a_random_sequence_using_the_value_from_the_proper_entry(i = n_aminoacids?
) ⇒ Object
#
do_generate_a_random_sequence_using_the_value_from_the_proper_entry
This variant will be guaranteed to use the value determined by the gtk entry.
#
507
508
509
510
511
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 507
def do_generate_a_random_sequence_using_the_value_from_the_proper_entry(
i = n_aminoacids?
)
do_generate_a_random_sequence(i)
end
|
#do_open_a_file_and_then_set_the_correct_values ⇒ Object
#
do_open_a_file_and_then_set_the_correct_values
#
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 531
def do_open_a_file_and_then_set_the_correct_values
filename = ::Gtk.select_file(self) {{ show_hidden: true,
add_these_shortcut_folders: ::Bioroebe.log_dir?,
current_folder: ::Bioroebe.log_dir?
}}
if File.exist? filename
_ = filename
if _.end_with? '.fasta'
require 'bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb'
sequence = Bioroebe.parse_fasta_file(_).sequence?
set_main_input(sequence)
do_evaluate_the_sequence
else
set_main_input(File.read(_).strip)
end
end
end
|
#do_properly_setup_the_tree_view ⇒ Object
#
do_properly_setup_the_tree_view
#
496
497
498
499
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 496
def do_properly_setup_the_tree_view
@tree_view.linear_sorting
@tree_view.
end
|
#enable_proper_sorting_for_the_list_store ⇒ Object
#
enable_proper_sorting_for_the_list_store
#
553
554
555
556
557
558
559
560
561
562
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 553
def enable_proper_sorting_for_the_list_store
@list_store.set_sort_func(1) { |_model, iter1, iter2|
iter2[1].to_i <=> iter1[1].to_i
}
end
|
#handle_CSS_rules ⇒ Object
Also known as:
handle_CSS
#
handle_CSS_rules (CSS tag, css tag)
#
157
158
159
160
161
162
163
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 157
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
add_these_custom_CSS_rules '
'
apply_the_CSS_rules
end
|
#main_font? ⇒ Boolean
143
144
145
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 143
def main_font?
USE_THIS_FONT
end
|
#mode? ⇒ Boolean
310
311
312
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 310
def mode?
@combo_box_for_the_sequence_type.text?
end
|
#n_aminoacids? ⇒ Boolean
428
429
430
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 428
def n_aminoacids?
@entry_for_n_entries_in_the_sequence.text?.to_s
end
|
#on_right_click_in_the_tree_view_deselect_the_selection ⇒ Object
#
on_right_click_in_the_tree_view_deselect_the_selection
#
567
568
569
570
571
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 567
def on_right_click_in_the_tree_view_deselect_the_selection
@tree_view.on_right_mouse_button_clicked {|widget, event|
@tree_view.deselect_everything
}
end
|
#padding? ⇒ Boolean
129
130
131
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 129
def padding?
8
end
|
#reset ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 106
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?
@list_store = nil
end
|
#run ⇒ Object
516
517
518
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 516
def run
run_super
end
|
#set_main_input(i) ⇒ Object
303
304
305
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 303
def set_main_input(i)
@entry_containing_the_sequence.set_text(i.to_s)
end
|
#slightly_smaller_font? ⇒ Boolean
#
slightly_smaller_font?
#
150
151
152
|
# File 'lib/bioroebe/gui/universal_widgets/random_sequence/random_sequence.rb', line 150
def slightly_smaller_font?
USE_THIS_SLIGHTLY_SMALLER_FONT
end
|