Class: Bioroebe::GUI::UniversalWidgets::FormatConverter
- Inherits:
-
UniversalWidgets::Base
- Object
- UniversalWidgets::Base
- Bioroebe::GUI::UniversalWidgets::FormatConverter
show all
- Includes:
- CommandlineArguments, Bioroebe::GUI
- Defined in:
- lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb
Overview
Constant Summary
collapse
- TITLE =
#
TITLE
Specify which title to use for this widget.
#
'Format Converter'
- 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_20
- 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
- TEXT1 =
'Available BLOSUM matrices:'
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) ⇒ FormatConverter
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 83
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
395
396
397
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 395
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
402
403
404
405
406
407
408
409
410
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 402
def self.run(
i = ARGV
)
r = ::Gtk.runner_factory(
::Bioroebe::GUI::Gtk::FormatConverter.new(i)
)
r.background_colour(:white)
return r
end
|
Instance Method Details
#border_size? ⇒ Boolean
124
125
126
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 124
def border_size?
0
end
|
#calculated_weight?(i) ⇒ Boolean
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 332
def calculated_weight?(i)
this_file = Bioroebe.file_molecular_weight
dataset = YAML.load_file(this_file)
weight = 0
if i.is_a?(String) and !i.empty?
chars = i.chars.sort
chars.each {|this_char|
value = dataset[this_char]
weight += value if value
}
end
weight -= (18.0 * (i.size - 1))
return weight.round(2)
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag, skeleton tag)
#
242
243
244
245
246
247
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 242
def connect_the_skeleton
abort_on_exception
vbox = create_vbox
_ = left_aligned_label('Format Converter')
_.make_bold
vbox.minimal(_, 2)
if first?
@entry_input_sequence.set_text(first?.to_s)
end
hbox = create_hbox
hbox.maximal(@entry_input_sequence, 1)
event_box = gtk_event_box(image_file_open)
event_box.hint = 'Click on this button in order to '\
'open a local .FASTA file.'
event_box.on_clicked {
do_open_a_local_file
}
hbox.minimal(event_box, 1)
vbox.add(hbox)
@entry_input_sequence.on_enter {
simulate_enter_click
}
hbox = create_hbox
button_do_convert = button('_Do convert', self, :use_mnemonics) {
:do_convert_the_file
}
button_do_convert.remove_background
button_do_convert.bblack1
button_do_convert.pad6px
hbox.minimal(button_do_convert, 4)
@combo_box = create_combo_box(
%w( to_fasta )
)
@combo_box.bblack1
@combo_box.first_is_active
hbox.minimal(@combo_box, 4)
vbox.minimal(hbox, 10)
window = runner_widget(nil, width?, height?, title?)
window << vbox
::UniversalWidgets.set_main_window(window)
::Bioroebe.cd(::Bioroebe.log_dir?)
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?)
window.top_left
run_main
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
219
220
221
222
223
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 219
def create_the_skeleton
@text_buffer = create_text_buffer
@text_view = create_text_view(@text_buffer)
create_user_input
end
|
304
305
306
307
308
309
310
311
312
313
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 304
def create_user_input
@entry_input_sequence = create_entry
@entry_input_sequence.hint = 'This will denote the current file.'
@entry_input_sequence.bblack1
@entry_input_sequence.yellow_background
@entry_input_sequence.pad5px
end
|
#do_convert_the_file ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 177
def do_convert_the_file
_ = main_entry?.text?
if _.empty?
(
main_entry?,
' Please assign a file to work with first. '
)
else
text = @combo_box.text?
case text
when 'to_fasta'
result = Bioroebe.genbank_to_fasta(File.read(_))
end
end
end
|
#do_open_a_local_file(this_widget = @parent_widget) ⇒ Object
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 156
def do_open_a_local_file(
this_widget = @parent_widget
)
require 'gtk_paradise/widgets/gtk3/select_file/select_file.rb'
widget = ::Gtk::SelectFile.new(this_widget) {{
current_folder: ::Bioroebe.log_dir?,
additional_directories: ::Bioroebe.log_dir?
}}
this_file = widget.do_pick_file.text.to_s
if File.exist?(this_file) and File.file?(this_file) dataset = File.read(this_file)
set_main_entry(this_file.to_s)
fill_with_this(dataset.to_s)
end
return this_file
end
|
#fill_with_this(i) ⇒ Object
325
326
327
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 325
def fill_with_this(i)
@text_buffer.set_text(i)
end
|
#handle_CSS_rules ⇒ Object
Also known as:
handle_CSS
#
handle_CSS_rules (CSS tag, css tag)
#
145
146
147
148
149
150
151
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 145
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_entry? ⇒ Boolean
388
389
390
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 388
def main_entry?
@entry_input_sequence
end
|
#main_font? ⇒ Boolean
131
132
133
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 131
def main_font?
USE_THIS_FONT
end
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 196
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i
when /^-?-?ubiquitin$/i,
/^-?-?ubi$/i
set_main_entry(
Bioroebe.return_ubiquitin_sequence
)
simulate_enter_click
end
end
end
|
#padding? ⇒ Boolean
117
118
119
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 117
def padding?
2
end
|
#reset ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 98
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?
end
|
#run ⇒ Object
228
229
230
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 228
def run
run_super
end
|
#set_main_entry(i) ⇒ Object
Also known as:
set_main_input_sequence
374
375
376
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 374
def set_main_entry(i)
@entry_input_sequence.set_text(i.to_s)
end
|
#set_main_input_sequence_and_evaluate_it(i) ⇒ Object
#
set_main_input_sequence_and_evaluate_it
#
381
382
383
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 381
def set_main_input_sequence_and_evaluate_it(i)
simulate_enter_click(i)
end
|
318
319
320
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 318
def set_parent_widget(i)
@parent_widget = i
end
|
#simulate_enter_click(_ = @entry_input_sequence.text?) ⇒ Object
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 353
def simulate_enter_click(
_ = @entry_input_sequence.text?
)
_.upcase!
_ = ::Bioroebe.filter_away_invalid_aminoacids(_)
@entry_input_sequence.set_text(_)
fill_the_table_data_with_this_sequence(_)
@label_n_aminoacids.set_text(
"This sequence has <b>#{_.size}</b> aminoacids."
)
@label_n_aminoacids.do_markify
@label_molecular_weight.set_text(
'The molecular weight is: <b>'+
calculated_weight?(_).to_s+'</b> Dalton'
)
@label_molecular_weight.do_markify
end
|
#slightly_smaller_font? ⇒ Boolean
#
slightly_smaller_font?
#
138
139
140
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 138
def slightly_smaller_font?
USE_THIS_SLIGHTLY_SMALLER_FONT
end
|
#smaller_font? ⇒ Boolean
235
236
237
|
# File 'lib/bioroebe/gui/universal_widgets/format_converter/format_converter.rb', line 235
def smaller_font?
SMALLER_FONT
end
|