Module: Bioroebe::GUI::LibUI::RandomSequence
- Includes:
- LibuiParadise::Extensions
- Defined in:
- lib/bioroebe/gui/libui/random_sequence/random_sequence.rb
Overview
Bioroebe::GUI::LibUI::RandomSequence
Constant Summary
collapse
- TITLE =
'Random Sequence - for DNA, RNA and aminoacids'
- HEIGHT =
500
Class Method Summary
collapse
-
.run ⇒ Object
# === Bioroebe::GUI::LibUI::RandomSequence.run ========================================================================= #.
Instance Method Summary
collapse
Class Method Details
.run ⇒ Object
#
Bioroebe::GUI::LibUI::RandomSequence.run
#
164
165
166
167
168
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 164
def self.run
object = Object.new.dup
object.extend(RandomSequence)
object.reset_then_run
end
|
Instance Method Details
#aminoacid_sequence? ⇒ Boolean
Also known as:
sequence?, main_sequence?
87
88
89
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 87
def aminoacid_sequence?
@entry_containing_the_sequence.text?.to_s
end
|
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
62
63
64
65
66
67
68
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 62
def create_skeleton
create_the_entries
@text_buffer = ui_text_view
end
|
#create_the_entries ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 73
def create_the_entries
@entry_containing_the_sequence = ui_entry
@entry_use_this_length = ui_entry(15)
end
|
#do_generate_a_random_sequence(n_aminoacids = :default) ⇒ Object
#
do_generate_a_random_sequence
#
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 134
def do_generate_a_random_sequence(
n_aminoacids = :default
)
case n_aminoacids
when nil, :default
n_aminoacids = GENERATE_N_AMINOACIDS_BY_DEFAULT
end
n_aminoacids = n_aminoacids.to_s
use_this_as_the_new_sequence = ::Bioroebe.create_random_aminoacids(n_aminoacids).to_s
array1 = ::Bioroebe.return_array_of_common_aminoacids
array2 = Bioroebe::CountAmountOfAminoacids.return_composition_hash(use_this_as_the_new_sequence).values.map(&:to_s)
zipped = array1.zip(array2) _ = ''.dup
zipped.each {|a, b|
_ << "#{a}: #{b}\n"
}
@text_buffer.set_text(_)
@entry_containing_the_sequence.set_text(use_this_as_the_new_sequence)
end
|
#do_generate_a_random_sequence_using_the_value_from_the_proper_entry(i = n_aminoacids?
) ⇒ Object
#
do_generate_a_random_sequence_using_the_value_from_the_proper_entry
This variant will be guaranteed to use the value determined by the gtk entry.
#
125
126
127
128
129
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 125
def do_generate_a_random_sequence_using_the_value_from_the_proper_entry(
i = n_aminoacids?
)
do_generate_a_random_sequence(i)
end
|
#initialize ⇒ Object
41
42
43
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 41
def initialize
reset
end
|
#n_aminoacids? ⇒ Boolean
157
158
159
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 157
def n_aminoacids?
@entry_use_this_length.text?.to_s
end
|
#reset ⇒ Object
56
57
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 56
def reset
end
|
#reset_then_run ⇒ Object
48
49
50
51
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 48
def reset_then_run
reset
run
end
|
#run ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/bioroebe/gui/libui/random_sequence/random_sequence.rb', line 95
def run
create_skeleton
main_window = ui_margined_window(TITLE, 1200, HEIGHT, 15)
outer_vbox = ui_padded_vbox
outer_vbox.minimal(@entry_containing_the_sequence)
button_generate_a_random_aminoacid_sequence = ui_button(
'Generate a random aminoacid sequence'
)
button_generate_a_random_aminoacid_sequence.on_clicked {
do_generate_a_random_sequence(n_aminoacids?)
}
outer_vbox.minimal(button_generate_a_random_aminoacid_sequence)
outer_vbox.minimal(@entry_use_this_length)
outer_vbox.minimal(
ui_text(
'Showing statistical information about the '\
'assigned aminoacid sequence next'
)
)
outer_vbox.maximal(@text_buffer)
main_window.child = outer_vbox
main_window.intelligent_exit
end
|