Class: Bioroebe::GUI::Gtk::ParsePdbFile

Inherits:
Gtk::Frame
  • Object
show all
Includes:
Gtk::BaseModule
Defined in:
lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb

Overview

Bioroebe::GUI::Gtk::ParsePdbFile

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
TITLE =
#

TITLE

#
' Parse a .pdb file '
WIDTH =
#

WIDTH

#
1200
HEIGHT =
#

HEIGHT

#
500
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_22

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ ParsePdbFile

#

initialize

#

54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 54

def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  super(" #{TITLE} ")
  make_bold
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.run(i = ARGV) ⇒ Object

#

Bioroebe::GUI::Gtk::ParsePdbFile.run

#

327
328
329
330
331
332
333
334
335
336
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 327

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::Bioroebe::GUI::Gtk::ParsePdbFile.new(i)
  r = ::Gtk.run
  r << _
  r.automatic_size_then_automatic_title
  r.middle_then_run
end

Instance Method Details

#a_new_file_has_been_loaded(i = @file_name.text?) ⇒ Object

#

a_new_file_has_been_loaded

Use this method to indicate that a new file has been loaded.

#

266
267
268
269
270
271
272
273
274
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 266

def a_new_file_has_been_loaded(
    i = @file_name.text?
  )
  @dataset = ::Bioroebe::ParsePdbFile.new(i) { :be_silent }
  update_the_scrolled_window_with_the_current_aminoacid_sequence
  update_the_label_protein_contans_n_alpha_helices
  update_the_aminoacid_sequence_is_label
  update_label_taxid
end

#add_how_many_alpha_helices_can_be_found_in_this_proteinObject

#

add_how_many_alpha_helices_can_be_found_in_this_protein

#

205
206
207
208
209
210
211
212
213
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 205

def add_how_many_alpha_helices_can_be_found_in_this_protein
  _ = gtk_hbox
  @label_protein_contans_n_alpha_helices = left_aligned_text('This protein contains <b>'+
       @dataset.n_alpha_helices?.to_s+
       '</b> alpha-helices.')
  @label_protein_contans_n_alpha_helices.make_selectable
  _ << @label_protein_contans_n_alpha_helices
  @outer_vbox.minimal(_, 2)
end

#add_information_about_how_many_atom_entries_are_part_of_that_pdb_fileObject

#

add_information_about_how_many_atom_entries_are_part_of_that_pdb_file

#

306
307
308
309
310
311
312
313
314
315
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 306

def add_information_about_how_many_atom_entries_are_part_of_that_pdb_file
  _ = gtk_hbox
  text = left_aligned_text(
    "\n<b>#{@dataset.n_atom_entries?.to_s}"\
    "</b> ATOM entries were found being part of this file."
  )
  text.make_selectable
  _ << text
  @outer_vbox.add(_)
end

#add_the_aminoacid_sequenceObject

#

add_the_aminoacid_sequence

#

189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 189

def add_the_aminoacid_sequence
  _ = gtk_vbox
  @text_for_the_aminoacid_sequence = left_aligned_text(
    'The aminoacid sequence (<b>'+@dataset.n_aminoacids?.to_s+
    '</b> aminoacids) is:'
  )
  @text_for_the_aminoacid_sequence.make_selectable
  _.minimal(@text_for_the_aminoacid_sequence, 10)
  update_the_scrolled_window_with_the_current_aminoacid_sequence
  _.minimal(@scrolled_window, 15)
  @outer_vbox.add(_)
end

#add_the_maximum_difference_between_the_atomsObject

#

add_the_maximum_difference_between_the_atoms

#

173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 173

def add_the_maximum_difference_between_the_atoms
  _ = gtk_hbox
  if @dataset
    text = left_aligned_text(
             'The maximum difference between the atoms is <b>'+
             @dataset.max_distance?.to_s.to_f.round(3).to_s+'</b>.'
           )
    text.make_selectable
    _ << text
  end
  @outer_vbox.add(_)
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)

92
93
94
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 92

def border_size?
  25
end

#connect_skeletonObject

#

connect_skeleton (connect tag)

#

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
163
164
165
166
167
168
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 120

def connect_skeleton
  abort_on_exception
  @outer_vbox = gtk_vbox
  @outer_vbox.set_border_width(18)
  _ = first_argument?.to_s
  if _.start_with? '--'
    _ = '' # In this case ignore it.
  end
  if File.exist? _
  else
    ::Bioroebe.no_file_exists_at(_)
  end
  @dataset = ::Bioroebe::ParsePdbFile.new(_) { :be_silent }
  hbox = gtk_hbox
  hbox.minimal(text('File name: '))
  @file_name = text_bold(File.absolute_path(_))
  hbox.minimal(@file_name)
  hbox.minimal(return_widget_containing_a_file_open_button, 9)
  @outer_vbox.minimal(hbox, 8)
  @outer_vbox.minimal(gtk_horizontal_spacer, 2)
  hbox = gtk_hbox
  @label_the_name_of_the_organism = text(
    'The name of the organism (Entry: '+
    '<span weight="bold" color="steelblue">ORGANISM_SCIENTIFIC</span>'+
    +') is'
  )
  @label_the_name_of_the_organism.do_markify
  hbox.minimal(@label_the_name_of_the_organism, 5)
  @outer_vbox.add(hbox)
  if @dataset
    taxid = @dataset.taxid_of_the_species?.to_s
    @label_taxid = text(
      '<span weight="bold" color="indigo">'+@dataset.name_of_the_species?.to_s+
      '</span>'+
      ' (Taxid: ➡️ '+
      '<span weight="bold"><a href="https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id='+taxid+'">'+
      taxid+'</a></span>; '+@dataset.organism_common?.to_s+')'
    )
    @label_taxid.make_selectable
    @label_taxid.do_markify
    @outer_vbox.add(hbox(@label_taxid))
  end
  add_information_about_how_many_atom_entries_are_part_of_that_pdb_file
  add_the_aminoacid_sequence
  add_how_many_alpha_helices_can_be_found_in_this_protein
  add_the_maximum_difference_between_the_atoms
  add(@outer_vbox)
  set_border_width(5)
end

#create_skeletonObject

#

create_skeleton (create tag)

#

113
114
115
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 113

def create_skeleton
  create_the_scrolled_window_containing_the_aminoacid_sequence
end

#create_the_scrolled_window_containing_the_aminoacid_sequenceObject

#

create_the_scrolled_window_containing_the_aminoacid_sequence

#

99
100
101
102
103
104
105
106
107
108
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 99

def create_the_scrolled_window_containing_the_aminoacid_sequence
  @text_buffer = gtk_text_buffer
  @text_view = gtk_text_view(@text_buffer)
  @scrolled_window = gtk_scrolled_window(@text_view) { :left_right }
  @scrolled_window.clear_background
  @scrolled_window.css_class('royalblue')
  @scrolled_window.bblack1
  @scrolled_window.width_height(400, 50)
  @scrolled_window.set_name('differently_coloured_selection')
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)

85
86
87
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 85

def padding?
  12
end

#resetObject

#

reset (reset tag)

#

70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 70

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

#return_widget_containing_a_file_open_buttonObject

#

return_widget_containing_a_file_open_button (open tag)

This is the widget with the “open file” functionality.

#

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 281

def return_widget_containing_a_file_open_button
  button_open_file = gtk_file_open_button
  button_open_file.bblack1
  button_open_file.on_click {
    create_a_new_file_chooser_dialog(
      button_open_file,
      'Open file'
    ) {{
      filter_for: '.pdb', # We only need .pdb files.
      additional_directories: Bioroebe.project_log_directory?+'pdb/'
    }}
    _ = ::Gtk.main_file?
    if _ and !_.empty?
      @file_name.set_text(
        _.to_s
      )
      a_new_file_has_been_loaded
    end
  }
  return button_open_file
end

#runObject

#

run (run tag)

#

320
321
322
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 320

def run
  create_skeleton_then_connect_skeleton
end

#update_label_taxidObject

#

update_label_taxid

#

249
250
251
252
253
254
255
256
257
258
259
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 249

def update_label_taxid
  taxid = @dataset.taxid_of_the_species?.to_s
  @label_taxid.set_text(
    '<span weight="bold" color="indigo">'+@dataset.name_of_the_species?.to_s+
    '</span>'+
    ' (Taxid: ➡️ '+
    '<span weight="bold"><a href="https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id='+taxid+'">'+
    taxid+'</a></span>; '+@dataset.organism_common?.to_s+')'
  )
  @label_taxid.do_markify
end

#update_the_aminoacid_sequence_is_labelObject

#

update_the_aminoacid_sequence_is_label

#

218
219
220
221
222
223
224
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 218

def update_the_aminoacid_sequence_is_label
  @text_for_the_aminoacid_sequence.set_text(
    'The aminoacid sequence (<b>'+@dataset.n_aminoacids?.to_s+
    '</b> aminoacids) is:'
  )
  @text_for_the_aminoacid_sequence.do_markify
end

#update_the_label_protein_contans_n_alpha_helicesObject

#

update_the_label_protein_contans_n_alpha_helices

#

229
230
231
232
233
234
235
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 229

def update_the_label_protein_contans_n_alpha_helices
  _ = 'This protein contains <b>'+
  @dataset.n_alpha_helices?.to_s+
  '</b> alpha-helices.'
  @label_protein_contans_n_alpha_helices.set_text(_)
  @label_protein_contans_n_alpha_helices.do_markify
end

#update_the_scrolled_window_with_the_current_aminoacid_sequenceObject

#

update_the_scrolled_window_with_the_current_aminoacid_sequence

#

240
241
242
243
244
# File 'lib/bioroebe/gui/gtk3/parse_pdb_file/parse_pdb_file.rb', line 240

def update_the_scrolled_window_with_the_current_aminoacid_sequence
  @scrolled_window.set_text(
    @dataset.aminoacid_sequence?.to_s
  )
end