Class: Bioroebe::GUI::UniversalWidgets::CalculateCellNumbersOfBacteria

Inherits:
UniversalWidgets::Base
  • Object
show all
Includes:
CommandlineArguments, Bioroebe::GUI
Defined in:
lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb

Overview

Bioroebe::GUI::UniversalWidgets::CalculateCellNumbersOfBacteria

Constant Summary collapse

TITLE =
#

TITLE

#
'Calculate cell numbers of bacteria'
WIDTH =
#

WIDTH

#
'65% or 500px minimum'
HEIGHT =
#

HEIGHT

#
'55% or 300px minimum'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:hack_26
FONT_FOR_THE_ENTRIES =
#

FONT_FOR_THE_ENTRIES

The entries must use a mono-spaced font.

#
:hack_22
TEXT_INPUT_THE_SEQUENCES =
#

TEXT_INPUT_THE_SEQUENCES

#
'Input the sequences that you wish '\
'to compare to one another'
TOOLTIP_HINT_FOR_THE_DO_ANALYSE_BUTTON =
#

TOOLTIP_HINT_FOR_THE_DO_ANALYSE_BUTTON

#
"Click on this button to analyse the given sequence. Make sure "\
"to use <b>newlines</b> in order to split the sequence at hand."
TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE =
#

TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE

This is the base-tooltip for the entry that retains our consensus sequence.

#
'This entry will contain the <b>consensus sequence</b>, '\
'derived from the above sequences.'
TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE_TRAILING_INFORMATION =
#

TOOLTIP_HINT_FOR_THE_ENTRY_CONSENSUS_SEQUENCE_TRAILING_INFORMATION

#
"\n\nTake note that in the event that there is <b>an even number of "\
"input sequences</b>, the entries defined before will take precedence. "\
"So, for instance, if you have four sequences in total, where two are "\
"ATTA and the next two are ATTT, then the consensus sequence is "\
"currently assumed to be <b>ATTA</b>."

Constants included from Bioroebe::GUI

ARRAY_ALL_GTK_WIDGETS, FONT_SIZE, OLD_VERBOSE_VALUE, Bioroebe::GUI::USE_THIS_FONT_FAMILY_FOR_GUI_APPLICATIONS

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Bioroebe::GUI

#disable_warnings, #enable_warnings, #log_dir?

Methods included from CommandlineArguments

#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

Methods included from ColoursForBase

#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) ⇒ CalculateCellNumbersOfBacteria

#

initialize

#


96
97
98
99
100
101
102
103
104
105
106
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.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

#

Bioroebe::GUI::UniversalWidgets::CalculateCellNumbersOfBacteria[]

#


403
404
405
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 403

def self.[](i = ARGV)
  new(i)
end

.run(i = ARGV) ⇒ Object

#

Bioroebe::GUI::Gtk::CalculateCellNumbersOfBacteria.run

#


410
411
412
413
414
415
416
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 410

def self.run(
    i = ARGV
  )
  ::Gtk.gtk_runner_factory(
    ::Bioroebe::GUI::Gtk::CalculateCellNumbersOfBacteria.new(i)
  )
end

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


204
205
206
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 204

def border_size?
  4
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag, skeleton tag)

#


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
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 374

def connect_the_skeleton
  abort_on_exception

  vbox = create_vbox
  vbox.minimal(@hbox1, 1)
  vbox.minimal(@hbox2, 1)
  vbox.minimal(@hbox3, 1)
  vbox.minimal(@a_hspacer, 5) if @a_hspacer
  vbox.minimal(
    simplified_button_box(@button_to_calculate_how_many_bacteria_will_exist), 5
  )

  window = runner_widget(nil, width?, height?, title?)
  window << 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?)
  window.top_left
  run_main
end

#create_the_boxesObject

#

create_the_boxes

#


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
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 338

def create_the_boxes
  # ======================================================================= #
  # === @hbox1
  # ======================================================================= #
  @hbox1 = create_hbox(
    bold_text('n bacteria (start)'),
    @entry_point_start_with_n_bacteria
  )

  # ======================================================================= #
  # === @hbox2
  # ======================================================================= #
  @hbox2 = create_hbox(
    bold_text('n doubling times'),
    @entry_point_use_n_divisions
  )

  # ======================================================================= #
  # === @hbox3
  # ======================================================================= #
  @hbox3 = create_hbox(
    bold_text('n bacteria (end)'),
    @entry_point_n_cells
  )
end

#create_the_button_to_calculate_how_many_bacteria_will_existObject

#

create_the_button_to_calculate_how_many_bacteria_will_exist (button tag)

#


254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 254

def create_the_button_to_calculate_how_many_bacteria_will_exist
  # ======================================================================= #
  # === @button_to_calculate_how_many_bacteria_will_exist
  # ======================================================================= #
  @button_to_calculate_how_many_bacteria_will_exist = bold_button(
    '_Calculate how many bacteria will exist after n rounds',
    self,
    :use_mnemonic
  ) {
    :do_the_calculation
  }
  @button_to_calculate_how_many_bacteria_will_exist.clear_background
  @button_to_calculate_how_many_bacteria_will_exist.bblack2
  @button_to_calculate_how_many_bacteria_will_exist.hint =
    "Click on this button in order to do the calculation\n"\
    "e. g. <b>how many bacteria we will have</b> "\
    "based on the above parameters."
  @button_to_calculate_how_many_bacteria_will_exist.on_hover(:powderblue)
end

#create_the_buttonsObject

#

create_the_buttons (buttons tag)

#


240
241
242
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 240

def create_the_buttons
  create_the_button_to_calculate_how_many_bacteria_will_exist
end

#create_the_entriesObject

#

create_the_entries (entry tag, entries tag)

#


277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 277

def create_the_entries
  # ======================================================================= #
  # === @entry_point_start_with_n_bacteria
  # ======================================================================= #
  @entry_point_start_with_n_bacteria = create_entry
  @entry_point_start_with_n_bacteria.default = 10
  @entry_point_start_with_n_bacteria.bblack1
  @entry_point_start_with_n_bacteria.on_click_select_all
  @entry_point_start_with_n_bacteria.do_center
  @entry_point_start_with_n_bacteria.on_key_press_event { |widget, event|
    if use_gtk3?
      do_the_calculation if Gdk::Keyval.to_name(event.keyval) == 'Return'
    else
      do_the_calculation
    end
  }
  @entry_point_start_with_n_bacteria.hint =
    'Input a <b>number</b> here, denoting how many bacteria '\
    'exist at the start.'

  # ======================================================================= #
  # === @entry_point_use_n_divisions
  # ======================================================================= #
  @entry_point_use_n_divisions = create_entry
  @entry_point_use_n_divisions.default = 10
  @entry_point_use_n_divisions.bblack1
  @entry_point_use_n_divisions.on_click_select_all
  @entry_point_use_n_divisions.do_center
  @entry_point_use_n_divisions.on_key_press_event { |widget, event|
    if use_gtk3?
      do_the_calculation if Gdk::Keyval.to_name(event.keyval) == 'Return'
    else
      do_the_calculation
    end
  }
  @entry_point_use_n_divisions.hint =
    'Input a <b>number</b> here, denoting how many cell '\
    'divisions the bacteria will undergo.'

  # ======================================================================= #
  # === @entry_point_n_cells
  # ======================================================================= #
  @entry_point_n_cells = create_entry
  @entry_point_n_cells.default = 0
  @entry_point_n_cells.bblack1
  @entry_point_n_cells.do_center
  @entry_point_n_cells.on_key_press_event { |widget, event|
    if use_gtk3?
      do_the_calculation if Gdk::Keyval.to_name(event.keyval) == 'Return'
    else
      do_the_calculation
    end
  }
  @entry_point_n_cells.hint =
    'The number here will be <b>the amount of bacteria '\
    'after n cell divisions</b>.'
end

#create_the_hspacerObject

#

create_the_hspacer

#


367
368
369
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 367

def create_the_hspacer
  @a_hspacer = create_hspacer
end

#create_the_scrolled_windowObject

#

create_the_scrolled_window

#


184
185
186
187
188
189
190
191
192
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 184

def create_the_scrolled_window
  # ======================================================================= #
  # === @scrolled_window
  # ======================================================================= #
  @scrolled_window = create_scrolled_window(@text_view)
  @scrolled_window.width_height(300, 400)
  @scrolled_window.pad4px
  @scrolled_window.bblack2
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


230
231
232
233
234
235
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 230

def create_the_skeleton
  create_the_entries
  create_the_buttons
  create_the_boxes # Must come after the entries.
  create_the_hspacer
end

#create_the_text_buffer_and_the_text_viewObject

#

create_the_text_buffer_and_the_text_view

#


163
164
165
166
167
168
169
170
171
172
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 163

def create_the_text_buffer_and_the_text_view
  # ======================================================================= #
  # === @text_buffer
  # ======================================================================= #
  @text_buffer = create_text_buffer
  # ======================================================================= #
  # === @text_view
  # ======================================================================= #
  @text_view = create_text_view(@text_buffer)
end

#do_the_calculationObject

#

do_the_calculation

This method will do the actual calculation part.

#


219
220
221
222
223
224
225
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 219

def do_the_calculation
  result = ::Bioroebe.calculate_exponential_growth(
    number_of_cells     = @entry_point_start_with_n_bacteria.text?,
    number_of_divisions = @entry_point_use_n_divisions.text?
  )
  @entry_point_n_cells.set_text(result.to_s)
end

#handle_CSS_rulesObject Also known as: handle_CSS

#

handle_CSS_rules (CSS tag)

#


130
131
132
133
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 130

def handle_CSS_rules
  use_gtk_paradise_project_CSS_file
  append_project_CSS_file
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


197
198
199
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 197

def padding?
  12
end

#resetObject

#

reset (reset tag)

#


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 111

def reset
  super() if respond_to?(:super)
  reset_the_internal_variables
  reset_the_base_module # This must come after reset_the_internal_variables().
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  # ======================================================================= #
  # === Set the title, width, height and the font in use.
  # ======================================================================= #
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  handle_CSS if use_gtk3?
end

#return_the_first_rowObject

#

return_the_first_row

#


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 138

def return_the_first_row
  _ = create_hbox
  top_label = left_aligned_label(
    TEXT_INPUT_THE_SEQUENCES
  )
  top_label.make_selectable
  top_label.center
  _.minimal(top_label)
  use_this_image = image_document_open
  if use_this_image
    event_box = event_box(use_this_image)
    if event_box
      event_box.hint = 'Click on this icon to open a local file.'
      event_box.on_clicked {
        do_open_and_assign_a_local_file
      }
      _.pack_end(event_box)
    end
  end
  return _
end

#runObject

#

run (run tag)

#


247
248
249
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 247

def run
  run_super
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


211
212
213
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 211

def smaller_font?
  SMALLER_FONT
end

#textview?Boolean

#

textview?

#

Returns:

  • (Boolean)


177
178
179
# File 'lib/bioroebe/gui/universal_widgets/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb', line 177

def textview?
  @text_view
end