Class: Bioroebe::GUI::Tk::AminoacidComposition

Inherits:
Object
  • Object
show all
Includes:
Colours, Tk
Defined in:
lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb

Overview

< Base # === Bioroebe::GUI::Tk::AminoacidComposition

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
TITLE =
#

TITLE

#
'Aminoacids Composition'
MAIN_FONT =
#

MAIN_FONT

#
TkFont.new(family: 'Helvetica', size: 20, weight: 'bold')
PADDING_TO_USE =
#

PADDING_TO_USE

#
{
  padx: 10,
  pady: 10
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ AminoacidComposition

#

initialize

#

59
60
61
62
63
64
65
66
67
68
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 59

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

Bioroebe::GUI::Tk::AminoacidComposition[]

#

198
199
200
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 198

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

Instance Method Details

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)

87
88
89
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 87

def commandline_arguments?
  @commandline_arguments
end

#do_analyse_the_aminoacid_sequence(i = @entry1.value) ⇒ Object

#

do_analyse_the_aminoacid_sequence

#

180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 180

def do_analyse_the_aminoacid_sequence(
    i = @entry1.value
  )
  i = i.dup if i.frozen?
  i.upcase!
  e 'Der input ist: '+i
  @entry1.value = i
  hash = Bioroebe.return_composition_from_this_aminoacid_sequence(i)
  array = hash.to_a.map {|inner_array| inner_array.map {|entry| entry.to_s }}
pp hash
pp array
pp i.encoding.to_s
e 'Unfinished: we must put this into a widget that displays this properly.'
end

#first_argument?Boolean Also known as: first?

#

first_argument?

#

Returns:

  • (Boolean)

94
95
96
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 94

def first_argument?
  @commandline_arguments.first
end

#resetObject

#

reset (reset tag)

#

73
74
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 73

def reset
end

#runObject

#

run (run tag)

#

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
169
170
171
172
173
174
175
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 101

def run
  root = TkRoot.new { title TITLE }
  root.geometry('800x500+0+0')

  # ======================================================================= #
  # Add a frame for the whole application.
  # ======================================================================= #
  outermost_frame = TkFrame.new(root)

  label = ::TkLabel.new(outermost_frame) {
    font(MAIN_FONT)
    text 'Aminoacid composition:'
    pack(side: 'top', padx: 10, pady: 10)
  }

  @text1 = TkVariable.new
  @entry1 = TkEntry.new(outermost_frame, textvariable: @text1) {
    font(MAIN_FONT)
    background 'moccasin'
  }
  @entry1.bind('Key', proc {|this_key|
    case this_key
    when 'Return','KP_Enter'
      do_analyse_the_aminoacid_sequence
    end
  }, '%K')

  @entry1.pack(outermost_frame)

  callback_do_analyse_the_aminoacid_sequence = proc {
    do_analyse_the_aminoacid_sequence
  }

  # ======================================================================= #
  # === The main button
  # ======================================================================= #
  frame_for_the_convert_button = TkFrame.new(
    outermost_frame,
    highlightbackground: 'black', 
    highlightthickness: 2,
    bd: 0,
    borderwidth: 2
  )
  frame_for_the_convert_button.pack
  button_convert = TkButton.new(frame_for_the_convert_button) {
    text 'Analyse the aminoacid composition'
    font(MAIN_FONT)
    relief :flat
    command callback_do_analyse_the_aminoacid_sequence
    pack
    borderwidth 5
  }

  # ======================================================================= #
  # === The quit-button and its special frame
  # ======================================================================= #
  frame_for_the_quit_button = TkFrame.new(
    outermost_frame,
    highlightbackground: 'black', 
    highlightthickness: 2,
    bd: 0,
    borderwidth: 2
  )
  frame_for_the_quit_button.pack
  button_quit = ::TkButton.new(frame_for_the_quit_button, text: 'Quit') {
    font(MAIN_FONT)
    relief :flat
    command proc {
      exit
    }
    pack
    borderwidth 5
  }
  ::Tk.run
end

#set_commandline_arguments(i = '') ⇒ Object

#

set_commandline_arguments

#

79
80
81
82
# File 'lib/bioroebe/gui/tk/aminoacid_composition/aminoacid_composition.rb', line 79

def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end