Class: Bioroebe::GUI::Tk::HammingDistance
- Inherits:
-
Tk::Base
- Object
- Tk::Base
- Bioroebe::GUI::Tk::HammingDistance
- Includes:
- Tk
- Defined in:
- lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb
Overview
Bioroebe::GUI::Tk::HammingDistance
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Hamming distance'
- MAIN_FONT =
#
MAIN_FONT
#
TkFont.new(family: 'Helvetica', size: 20, weight: 'bold')
- SMALLER_FONT =
#
SMALLER_FONT
#
TkFont.new(family: 'Helvetica', size: 16, weight: 'bold')
- USE_THIS_BACKGROUND_COLOUR =
#
USE_THIS_BACKGROUND_COLOUR
#
'mintcream'
- MONOSPACED_FONT =
#
MONOSPACED_FONT
#
TkFont.new(family: 'Hack', size: 22, weight: 'bold')
- PADDING_TO_USE =
#
PADDING_TO_USE
#
{ padx: 10, pady: 10 }
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === Bioroebe::GUI::Tk::HammingDistance[] ========================================================================= #.
Instance Method Summary collapse
-
#compare_the_two_sequences ⇒ Object
(also: #do_compare, #do_calculate_the_differences)
# === compare_the_two_sequences.
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ HammingDistance
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#seq1? ⇒ Boolean
# === seq1? ========================================================================= #.
-
#seq2? ⇒ Boolean
# === seq2? ========================================================================= #.
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ HammingDistance
#
initialize
#
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 72 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::HammingDistance[]
#
254 255 256 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 254 def self.[](i = '') new(i) end |
Instance Method Details
#compare_the_two_sequences ⇒ Object Also known as: do_compare, do_calculate_the_differences
#
compare_the_two_sequences
This is the method that will compare the two sequences.
#
241 242 243 244 245 246 247 248 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 241 def compare_the_two_sequences hamming_distance_object = ::Bioroebe::HammingDistance.new( "#{seq1?} #{seq2?}" ) { :be_quiet } _ = hamming_distance_object.n_differences?.to_s @entry_n_differences.delete(0,'end') # Clear it first. @entry_n_differences.insert(0, _) end |
#reset ⇒ Object
#
reset (reset tag)
#
86 87 88 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 86 def reset super() end |
#run ⇒ Object
#
run (run tag)
#
93 94 95 96 97 98 99 100 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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 93 def run root = TkRoot.new { title TITLE background USE_THIS_BACKGROUND_COLOUR } root.geometry('700x400+0+0') root.minsize(400, 200) # ======================================================================= # # Add a frame for the whole application. # ======================================================================= # outermost_frame = TkFrame.new(root) { background USE_THIS_BACKGROUND_COLOUR } label = ::TkLabel.new(outermost_frame) { font(MAIN_FONT) text TITLE pack( side: 'top', padx: 10, pady: 10 ) background USE_THIS_BACKGROUND_COLOUR } ::TkLabel.new(outermost_frame) { font SMALLER_FONT text "The Hamming distance - a number - measures "\ "the number of\npositions at which two strings "\ "of equal length are different." pack( side: 'top', # must be top-aligned to appear on top. padx: 5, pady: 5, fill: 'both' ) background USE_THIS_BACKGROUND_COLOUR } @text1 = TkVariable.new( 'AGUUCGAUGGAAAATAT' ) # ======================================================================= # # === @entry1 # ======================================================================= # @entry1 = TkEntry.new(outermost_frame, textvariable: @text1) { font(MONOSPACED_FONT) background 'lightsteelblue' } @entry1.pack(outermost_frame) @entry1.configure(width: 35) @text2 = TkVariable.new( 'AGUCCGGUCGAAAAAAA' ) # ======================================================================= # # === @entry2 # ======================================================================= # @entry2 = TkEntry.new(outermost_frame, textvariable: @text2) { font(MONOSPACED_FONT) background 'lightsteelblue' } @entry2.pack(outermost_frame) @entry2.configure(width: 35) callback_do_compare = proc { do_compare } # ======================================================================= # # === The convert-button with its special frame comes next # ======================================================================= # = TkFrame.new( outermost_frame, highlightbackground: 'black', highlightthickness: 2, bd: 0, borderwidth: 2 ) .pack = TkButton.new() { text 'Compare the two sequences' font(MAIN_FONT) relief :flat command callback_do_compare pack borderwidth 5 } @text3 = tk_variable # ======================================================================= # # === @entry_n_differences (main entry tag) # # This is the third (and last) entry. # ======================================================================= # @entry_n_differences = TkEntry.new(outermost_frame, textvariable: @text3) { font(MAIN_FONT) width 250 background 'yellow' borderwidth 5 relief 'groove' } @entry_n_differences.configure(width: 25) @entry_n_differences.configure(highlightbackground: 'blue') @entry_n_differences.configure(highlightcolor: 'green') @entry_n_differences.pack(outermost_frame) # ======================================================================= # # === The quit-button and its special frame # ======================================================================= # = TkFrame.new( outermost_frame, highlightbackground: 'black', highlightthickness: 2, bd: 0, borderwidth: 2 ) .pack = ::TkButton.new(, text: 'Quit') { font(MAIN_FONT) relief :flat command proc { exit } pack borderwidth 5 } ::Tk.run end |
#seq1? ⇒ Boolean
#
seq1?
#
232 233 234 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 232 def seq1? @text1 end |
#seq2? ⇒ Boolean
#
seq2?
#
225 226 227 |
# File 'lib/bioroebe/gui/tk/hamming_distance/hamming_distance.rb', line 225 def seq2? @text2 end |