Class: Bioroebe::GUI::UniversalWidgets::NucleotideAnalyser
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::NucleotideAnalyser
show all
- Includes:
- CommandlineArguments, Bioroebe::GUI
- Defined in:
- lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb
Overview
Constant Summary
collapse
- TITLE =
#
TITLE
Specify which title to use for this widget.
#
'Nucleotide Analyser'
- WIDTH =
'75% or 1200px minimum'
- HEIGHT =
'55% or 500px 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
- COLOUR_FOR_NON_MATCHES =
#
COLOUR_FOR_NON_MATCHES
This is the colour that will be used for non-matching nucleotides.
#
:magenta
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) ⇒ NucleotideAnalyser
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 96
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
545
546
547
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 545
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::NucleotideAnalyser.run
#
552
553
554
555
556
557
558
559
560
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 552
def self.run(
i = ARGV
)
r = ::Gtk.runner_factory(
::Bioroebe::GUI::Gtk::NucleotideAnalyser.new(i)
)
r.background_colour(:white)
return r
end
|
Instance Method Details
#border_size? ⇒ Boolean
391
392
393
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 391
def border_size?
2
end
|
#clear_table ⇒ Object
224
225
226
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 224
def clear_table
@list_store.clear
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag, skeleton tag)
#
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
530
531
532
533
534
535
536
537
538
539
540
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 502
def connect_the_skeleton
abort_on_exception
@outer_vbox = create_vbox
_ = first_argument?.to_s
@outer_vbox.minimal(@entry_input_sequence, 2)
@entry_input_sequence.set_text(@sequence.to_s)
@outer_vbox.minimal(@text_this_sequence_contains, 2)
@outer_vbox.minimal(horizontal_spacer)
@tree_view.all_are_sortable scrolled_window = create_scrolled_window(@tree_view) { :never_always }
scrolled_window.set_size_request(420, 260)
@outer_vbox.minimal(scrolled_window, 5)
@outer_vbox.minimal(gtk_horizontal_spacer)
update_the_labels
@outer_vbox.minimal(@label_GC_content)
@outer_vbox.minimal(@label_AT_content)
hbox = create_hbox
hbox.maximal(@button_reset, 1)
hbox.maximal(@button_reset_the_input_sequence, 1)
hbox.maximal(@button_open_file, 1)
@outer_vbox.minimal(hbox, 2)
window = runner_widget(nil, width?, height?, title?)
window << @outer_vbox
::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?)
do_style_all_buttons_in_a_uniform_manner
window.top_left
run_main
end
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 348
def create_the_buttons
@button_reset = button('_Reset the table')
@button_reset.hint = 'This button will clear the table-result '\
'shown above.'
@button_reset.on_clicked {
clear_table
}
@button_reset_the_input_sequence = button('Reset the _input sequence')
@button_reset_the_input_sequence.enable_markup
@button_reset_the_input_sequence.hint = 'This button will '\
'reset (aka clear) the input sequence. The input sequence is kept '\
'on top of this widget, as a gtk-entry.'
@button_reset_the_input_sequence.on_clicked {
do_reset_the_input_sequence
}
@button_open_file = button('_Open file')
@button_open_file.enable_markup
@button_open_file.hint = 'This button can be used to open a local'\
'file, typically a FASTA (.fasta) file.'
@button_open_file.on_clicked {
do_open_a_local_file
}
end
|
#create_the_entries ⇒ Object
#
create_the_entries (entry tag)
#
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 137
def create_the_entries
@entry_input_sequence = entry
@entry_input_sequence.default_values
@entry_input_sequence.hint = 'The sequence will be evaluated '\
'whenever it is changed, as-is. Hit the <b>enter</b> key '\
'to change it, for convenience.'
@entry_input_sequence.on_changed {
update_the_main_sequence_variable
update_this_sequence_contains_n_nucleotides
update_the_table_dataset
update_the_labels
}
@entry_input_sequence.on_enter_key {
sanitize_the_sequence
do_analyse_the_sequence
update_this_sequence_contains_n_nucleotides(
return_how_many_nucleotides_this_sequence_contains
)
}
end
|
#create_the_labels ⇒ Object
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 430
def create_the_labels
@label_GC_content = left_aligned_label
@label_GC_content.make_selectable
_ = ::Bioroebe.gc_content(@sequence, 1) @label_AT_content = left_aligned_label(
'The <b>AT content</b> (A+T) is: <b>'+
(100.0 - _.to_f).round(1).to_s+'%</b>'
)
@label_AT_content.make_selectable
@text_this_sequence_contains = left_aligned_label
@text_this_sequence_contains.make_selectable
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
455
456
457
458
459
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 455
def create_the_skeleton
create_the_labels
create_the_entries
create_the_buttons
end
|
#dna_sequence? ⇒ Boolean
174
175
176
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 174
def dna_sequence?
@entry_input_sequence.text?
end
|
#do_analyse_the_sequence ⇒ Object
Also known as:
update_the_table_dataset
#
do_analyse_the_sequence
#
209
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 209
def do_analyse_the_sequence
clear_table
_ = return_dataset_based_on_this_sequence.each_slice(3).to_a
_.shift
populate_this_list_store3(
@list_store, _.compact
)
end
|
#do_open_a_local_file ⇒ Object
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 246
def do_open_a_local_file
_ = open_local_file if File.exist?(_) and File.file?(_)
if _.end_with?('.fasta') or _.end_with?('.fa')
content_of_the_file = Bioroebe.parse_fasta(_).body?
else
content_of_the_file = File.read(_).to_s
end
set_main_entry(content_of_the_file)
end
end
|
301
302
303
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 301
def do_reset_the_input_sequence
@entry_input_sequence.clear
end
|
200
201
202
203
204
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 200
def do_style_all_buttons_in_a_uniform_manner
return_all_buttons.each {|this_button|
this_button.bblack1
}
end
|
#entry_input_sequence? ⇒ Boolean
Also known as:
main_entry?
#
entry_input_sequence?
#
167
168
169
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 167
def entry_input_sequence?
@entry_input_sequence
end
|
#handle_CSS_rules ⇒ Object
Also known as:
handle_CSS
#
handle_CSS_rules (CSS tag, css tag)
#
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 412
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
add_these_custom_CSS_rules '
#custom_treeview.view header button {
color: royalblue;
font-weight: bold;
font-size: larger;
padding: 8px;
}
'
apply_the_CSS_rules
end
|
#initialize_dataset_based_on_the_main_sequence_and_create_the_associated_widgets(i = @sequence) ⇒ Object
#
initialize_dataset_based_on_the_main_sequence_and_create_the_associated_widgets
#
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 478
def initialize_dataset_based_on_the_main_sequence_and_create_the_associated_widgets(
i = @sequence
)
@dataset = return_dataset_based_on_this_sequence(i)
@tree_view, @list_store = gtk_table3(
@dataset
) {{
cell_renderer_text1: :align_to_the_middle,
cell_renderer_text2: :align_to_the_middle
}}
@tree_view.bblack2
@tree_view.pad10px
@tree_view.set_name('custom_treeview')
@tree_view.first_column?.center
@tree_view.second_column?.center
@tree_view.
end
|
#main_font? ⇒ Boolean
398
399
400
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 398
def main_font?
USE_THIS_FONT
end
|
#open_local_file ⇒ Object
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 231
def open_local_file
widget = ::Gtk::SelectFile.new(self) {{
current_folder: ::Bioroebe.log_dir?
}}
this_file = widget.do_pick_file.text.to_s
return this_file
end
|
#padding? ⇒ Boolean
384
385
386
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 384
def padding?
2
end
|
#reset ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 111
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?
@sequence = 'GCTATGCATGCATGCTTTTTTTTTTTAGTCAGTCAGTCGATGCATGC'\
'ATGCTAGTCAGTCAGTCGATGTGCATGCTAGTCAGTCAGTCGATGCA'
initialize_dataset_based_on_the_main_sequence_and_create_the_associated_widgets
end
|
#return_dataset_based_on_this_sequence(sequence = @entry_input_sequence.text?) ⇒ Object
#
return_dataset_based_on_this_sequence
#
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 275
def return_dataset_based_on_this_sequence(
sequence = @entry_input_sequence.text?
)
total = sequence.size
dataset = [ 'Nucleotide','amount','Percentage',
'A', sequence.count('A').to_s, ((sequence.count('A').to_f * 100) / total).round(1).to_s+'%',
'T', sequence.count('T').to_s, ((sequence.count('T').to_f * 100) / total).round(1).to_s+'%',
'C', sequence.count('C').to_s, ((sequence.count('C').to_f * 100) / total).round(1).to_s+'%',
'G', sequence.count('G').to_s, ((sequence.count('G').to_f * 100) / total).round(1).to_s+'%'
]
return dataset
end
|
#return_how_many_nucleotides_this_sequence_contains(i = @entry_input_sequence.text?) ⇒ Object
#
return_how_many_nucleotides_this_sequence_contains
#
292
293
294
295
296
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 292
def return_how_many_nucleotides_this_sequence_contains(
i = @entry_input_sequence.text?
)
"This sequence contains <b>#{i.size.to_s}</b> nucleotides."
end
|
#run ⇒ Object
464
465
466
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 464
def run
run_super
end
|
#sanitize_the_sequence ⇒ Object
#
sanitize_the_sequence
#
308
309
310
311
312
313
314
315
316
317
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 308
def sanitize_the_sequence
if @entry_input_sequence.text?
if @entry_input_sequence.text?.include? '-'
new_sequence = @entry_input_sequence.text?.delete('-')
@sequence = new_sequence
@entry_input_sequence.set_text(new_sequence)
@dataset = return_dataset_based_on_this_sequence(@entry_input_sequence.text?)
end
end
end
|
#set_main_entry(i) ⇒ Object
Also known as:
set_dna_sequence
341
342
343
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 341
def set_main_entry(i)
@entry_input_sequence.set_text(i.to_s)
end
|
#slightly_smaller_font? ⇒ Boolean
#
slightly_smaller_font?
#
405
406
407
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 405
def slightly_smaller_font?
USE_THIS_SLIGHTLY_SMALLER_FONT
end
|
#smaller_font? ⇒ Boolean
471
472
473
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 471
def smaller_font?
SMALLER_FONT
end
|
#update_the_AT_content_label ⇒ Object
#
update_the_AT_content_label
#
329
330
331
332
333
334
335
336
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 329
def update_the_AT_content_label
_ = ::Bioroebe.gc_content(@sequence, 1) @label_AT_content.set_text(
"The <b>AT content</b> (A+T) is: <b>"\
"#{(100.0 - _.to_f).round(1).to_s}%</b>"
)
@label_AT_content.do_markify
end
|
#update_the_GC_content_label ⇒ Object
#
update_the_GC_content_label
#
181
182
183
184
185
186
187
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 181
def update_the_GC_content_label
_ = ::Bioroebe.gc_content(@sequence, 1) @label_GC_content.set_text(
'The <b>GC content</b> (G+C) is: <b>'+_.to_s+'%</b>'
)
@label_GC_content.do_markify
end
|
#update_the_labels ⇒ Object
192
193
194
195
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 192
def update_the_labels
update_the_GC_content_label
update_the_AT_content_label
end
|
#update_the_main_sequence_variable ⇒ Object
#
update_the_main_sequence_variable
#
322
323
324
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 322
def update_the_main_sequence_variable
@sequence = @entry_input_sequence.text?.delete('-')
end
|
#update_this_sequence_contains_n_nucleotides(i = return_how_many_nucleotides_this_sequence_contains) ⇒ Object
#
update_this_sequence_contains_n_nucleotides
#
264
265
266
267
268
269
270
|
# File 'lib/bioroebe/gui/universal_widgets/nucleotide_analyser/nucleotide_analyser.rb', line 264
def update_this_sequence_contains_n_nucleotides(
i =
return_how_many_nucleotides_this_sequence_contains
)
@text_this_sequence_contains.set_text(i.to_s)
@text_this_sequence_contains.do_markify
end
|