Class: Bioroebe::GUI::Gtk::FormatConverter
- Inherits:
-
Gtk::Box
- Object
- Gtk::Box
- Bioroebe::GUI::Gtk::FormatConverter
- Includes:
- Gtk::BaseModule
- Defined in:
- lib/bioroebe/gui/gtk3/format_converter/format_converter.rb
Overview
Bioroebe::GUI::Gtk::FormatConverter
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Format Converter'
- WIDTH =
#
WIDTH
#
'60% or 800px minimum'
- HEIGHT =
#
HEIGHT
#
800
- USE_THIS_FONT =
#
USE_THIS_FONT
#
:dejavu_condensed_20
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === Bioroebe::GUI::Gtk::FormatConverter.run ========================================================================= #.
Instance Method Summary collapse
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#calculated_weight?(i) ⇒ Boolean
# === calculated_weight? ========================================================================= #.
-
#connect_skeleton ⇒ Object
# === connect_skeleton (connect tag) ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag) ========================================================================= #.
-
#create_user_input ⇒ Object
# === create_user_input ========================================================================= #.
-
#do_convert_the_file ⇒ Object
# === do_convert_the_file ========================================================================= #.
-
#do_open_a_local_file(this_widget = @parent_widget) ⇒ Object
# === do_open_a_local_file ========================================================================= #.
-
#fill_with_this(i) ⇒ Object
# === fill_with_this ========================================================================= #.
-
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ FormatConverter
constructor
# === initialize ========================================================================= #.
-
#main_entry? ⇒ Boolean
# === main_entry? ========================================================================= #.
-
#menu(i = commandline_arguments? ) ⇒ Object
# === menu (menu tag) ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#set_main_entry(i) ⇒ Object
(also: #set_main_input_sequence)
# === set_main_entry ========================================================================= #.
-
#set_main_input_sequence_and_evaluate_it(i) ⇒ Object
# === set_main_input_sequence_and_evaluate_it ========================================================================= #.
-
#set_parent_widget(i) ⇒ Object
# === set_parent_widget ========================================================================= #.
-
#simulate_enter_click(_ = @entry_input_sequence.text?) ⇒ Object
# === simulate_enter_click ========================================================================= #.
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ FormatConverter
#
initialize
#
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 53 def initialize( commandline_arguments = ARGV, run_already = true ) super(:vertical) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
Class Method Details
.run(i = ARGV) ⇒ Object
#
Bioroebe::GUI::Gtk::FormatConverter.run
#
331 332 333 334 335 336 337 338 339 340 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 331 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::Bioroebe::GUI::Gtk::FormatConverter.new(i) r = ::Gtk.run r << _ r.automatic_size_then_automatic_title r.top_left_then_run end |
Instance Method Details
#border_size? ⇒ Boolean
#
border_size?
#
90 91 92 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 90 def border_size? 0 end |
#calculated_weight?(i) ⇒ Boolean
#
calculated_weight?
#
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 125 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 # ======================================================================= # # Must deduct water too. # ======================================================================= # weight -= (18.0 * (i.size - 1)) return weight.round(2) end |
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
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 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 248 def connect_skeleton abort_on_exception _ = gtk_left_aligned_label('Format Converter') _.make_bold minimal(_, 2) if first? @entry_input_sequence.set_text(first?.to_s) end hbox = gtk_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) add(hbox) @entry_input_sequence.on_enter { simulate_enter_click } hbox = gtk_hbox # ======================================================================= # # === button_do_convert # ======================================================================= # = ('_Do convert') .remove_background .bblack1 .pad6px .on_clicked { do_convert_the_file } hbox.minimal(, 4) @combo_box = gtk_combo_box( %w( to_fasta ) ) @combo_box.bblack1 @combo_box.first_is_active hbox.minimal(@combo_box, 4) minimal(hbox, 10) scrolled_window = gtk_scrolled_window(@text_view) { :always } scrolled_window.width_height(300, 600) scrolled_window.bblack1 scrolled_window.css_class('pad2px') minimal(scrolled_window, 2) @label_n_aminoacids = left_aligned_text minimal(@label_n_aminoacids, 2) @label_molecular_weight = left_aligned_text minimal(@label_molecular_weight, 2) end |
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
216 217 218 219 220 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 216 def create_skeleton @text_buffer = gtk_text_buffer @text_view = gtk_text_view(@text_buffer) create_user_input end |
#create_user_input ⇒ Object
#
create_user_input
#
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 97 def create_user_input # ======================================================================= # # === @entry_input_sequence # ======================================================================= # @entry_input_sequence = gtk_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
#
do_convert_the_file
#
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 189 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? pp text pp text pp text pp _ pp _ pp _ case text when 'to_fasta' pp File.read(_) result = Bioroebe.genbank_to_fasta(File.read(_)) pp result end end end |
#do_open_a_local_file(this_widget = @parent_widget) ⇒ Object
#
do_open_a_local_file
#
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 302 def do_open_a_local_file( = @parent_widget ) require 'gtk_paradise/widgets/gtk3/select_file/select_file.rb' = ::Gtk::SelectFile.new() {{ current_folder: ::Bioroebe.log_dir?, additional_directories: ::Bioroebe.log_dir? }} this_file = .do_pick_file.text.to_s if File.exist?(this_file) and File.file?(this_file) # Ensure that it really is a 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
#
fill_with_this
#
118 119 120 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 118 def fill_with_this(i) @text_buffer.set_text(i) end |
#main_entry? ⇒ Boolean
#
main_entry?
#
181 182 183 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 181 def main_entry? @entry_input_sequence end |
#menu(i = commandline_arguments? ) ⇒ Object
#
menu (menu tag)
#
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 225 def ( i = commandline_arguments? ) if i.is_a? Array i.each {|entry| (entry) } else case i # ===================================================================== # # === gtk_aminoacid_composition --ubi # ===================================================================== # when /^-?-?ubiquitin$/i, /^-?-?ubi$/i set_main_entry( Bioroebe.return_ubiquitin_sequence ) simulate_enter_click end end end |
#padding? ⇒ Boolean
#
padding?
#
83 84 85 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 83 def padding? 2 end |
#reset ⇒ Object
#
reset (reset tag)
#
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 68 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT) use_gtk_paradise_project_css_file append_project_CSS_file infer_the_size_automatically end |
#run ⇒ Object
#
run (run tag)
#
322 323 324 325 326 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 322 def run ::Bioroebe.cd(::Bioroebe.log_dir?) create_skeleton_then_connect_skeleton end |
#set_main_entry(i) ⇒ Object Also known as: set_main_input_sequence
#
set_main_entry
#
167 168 169 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 167 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
#
174 175 176 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 174 def set_main_input_sequence_and_evaluate_it(i) simulate_enter_click(i) end |
#set_parent_widget(i) ⇒ Object
#
set_parent_widget
#
111 112 113 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 111 def (i) @parent_widget = i end |
#simulate_enter_click(_ = @entry_input_sequence.text?) ⇒ Object
#
simulate_enter_click
#
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/bioroebe/gui/gtk3/format_converter/format_converter.rb', line 146 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 |