Class: Bioroebe::GUI::UniversalWidgets::FastaTableWidget
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::FastaTableWidget
show all
- Includes:
- CommandlineArguments, Bioroebe::GUI
- Defined in:
- lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb
Overview
Constant Summary
collapse
- TITLE =
#
TITLE
Specify which title to use for this widget.
#
'Fasta Table Widget'
- WIDTH =
'75% or 2000px 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
[
'Local Path',
'File size',
'n nucleotides',
'%GC'
]
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) ⇒ FastaTableWidget
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.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
621
622
623
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 621
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
628
629
630
631
632
633
634
635
636
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 628
def self.run(
i = ARGV
)
r = ::Gtk.runner_factory(
::Bioroebe::GUI::Gtk::FastaTableWidget.new(i)
)
r.background_colour(:white)
return r
end
|
Instance Method Details
#append_this_fasta_file(i) ⇒ Object
Also known as:
append_this_file
#
append_this_fasta_file
#
526
527
528
529
530
531
532
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 526
def append_this_fasta_file(i)
unless @all_fasta_files.include?(i)
if i.end_with?('.fa','.fasta','.txt','.md')
@all_fasta_files << i
end
end
end
|
#border_size? ⇒ Boolean
391
392
393
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 391
def border_size?
0
end
|
#clear_table ⇒ Object
224
225
226
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 224
def clear_table
@list_store.clear
end
|
#clear_the_old_dataset ⇒ Object
#
clear_the_old_dataset
#
537
538
539
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 537
def clear_the_old_dataset
@all_fasta_files.clear
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag, skeleton tag)
#
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 593
def connect_the_skeleton
abort_on_exception
populate_the_list_store_with_the_default_dataset
scrolled_window = create_scrolled_window(@view) { :always }
scrolled_window.width_height(540, 500)
@outer_vbox = create_vbox
@outer_vbox.minimal(scrolled_window, 14)
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_padding(padding?)
window.set_border_size(border_size?)
window.set_size_request(width?, height?)
window.set_default_size(width?, height?)
style_the_label_widget
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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
497
498
499
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 497
def create_the_skeleton
create_the_view
end
|
#create_the_view ⇒ Object
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 475
def create_the_view
@list_store = ::Gtk::ListStore.new(
String,
String,
String,
String
)
@view = create_tree_view(@list_store)
@view. = HEADER_TO_USE_FOR_THE_TREE_VIEW
@view.make_sortable
@view.
@view.enable_search
@view.deselect_on_right_click_event
deselect_the_main_treeview
end
|
#deselect_the_main_treeview ⇒ Object
#
deselect_the_main_treeview
#
412
413
414
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 412
def deselect_the_main_treeview
@view.deselect
end
|
#dna_sequence? ⇒ Boolean
174
175
176
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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)
#
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 419
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
add_these_custom_CSS_rules '
treeview.view header button {
color: black;
background-color: oldlace;
border: 1px solid black;
margin: 1px;
}
'
apply_the_CSS_rules
end
|
#list_store? ⇒ Boolean
Also known as:
liststore?
468
469
470
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 468
def list_store?
@list_store
end
|
#main_font? ⇒ Boolean
398
399
400
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 398
def main_font?
USE_THIS_FONT
end
|
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 574
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
if i and File.exist?(i)
clear_the_old_dataset
append_this_fasta_file(i)
end
end
end
|
#open_local_file ⇒ Object
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.rb', line 384
def padding?
2
end
|
#populate_the_list_store_with_the_default_dataset ⇒ Object
#
populate_the_list_store_with_the_default_dataset
#
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 437
def populate_the_list_store_with_the_default_dataset
array = @all_fasta_files.map {|path|
parse_fasta_object = ::Bioroebe.parse_fasta(path) { :be_quiet }
n_nucleotides = parse_fasta_object.n_nucleotides?
gc_content = parse_fasta_object.gc_content gc_content = gc_content.round(2)
[path, File.size(path), n_nucleotides, gc_content]
}.sort_by {|path, size, n_nucleotides, gc_content|
size
}
@list_store.set_sort_func(1) { |_model, iter1, iter2|
iter2[1].to_s.to_f <=> iter1[1].to_s.to_f
}
@list_store.set_sort_func(2) { |_model, iter1, iter2|
iter2[2].to_s.to_f <=> iter1[2].to_s.to_f
}
populate_this_list_store_with_that_array4(@list_store, array)
end
|
#reset ⇒ Object
110
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/fasta_table_widget/fasta_table_widget.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?
@use_this_directory = ::Bioroebe.log_directory?+'fasta/'
@all_fasta_files = Dir[@use_this_directory+'*.fasta']
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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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
504
505
506
507
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 504
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/fasta_table_widget/fasta_table_widget.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
|
#second_column? ⇒ Boolean
519
520
521
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 519
def second_column?
@view.columns?[1]
end
|
#set_main_entry(i) ⇒ Object
Also known as:
set_dna_sequence
341
342
343
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.rb', line 405
def slightly_smaller_font?
USE_THIS_SLIGHTLY_SMALLER_FONT
end
|
#smaller_font? ⇒ Boolean
512
513
514
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 512
def smaller_font?
SMALLER_FONT
end
|
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
# File 'lib/bioroebe/gui/universal_widgets/fasta_table_widget/fasta_table_widget.rb', line 544
def style_the_label_widget
_ = hbox
label = text('FASTA files')
label.left_align
label.fonty(main_font?)
label.make_bold
label.css_class('darkblue')
label.pad4px
_.minimal(label, 10)
event_box = event_box(image_document_open)
event_box.on_clicked {
filename = ::Gtk.select_file(@parent_widget) {{ current_folder: return_pwd,
show_hidden: true,
add_these_shortcut_folders: Bioroebe.fasta_dir?
}}
if filename and File.exist?(filename)
append_this_file(filename)
liststore?.clear
populate_the_list_store_with_the_default_dataset
end
}
@outer_vbox.minimal event_box, 10
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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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/fasta_table_widget/fasta_table_widget.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
|