Class: Bioroebe::ColourizeSequence
- Inherits:
-
Base
- Object
- Base
- Bioroebe::ColourizeSequence
show all
- Defined in:
- lib/bioroebe/colours/colourize_sequence.rb
Overview
Bioroebe::ColourizeSequence
Constant Summary
collapse
- DEFAULT_NUCLEOTIDE_SEQUENCE =
#
DEFAULT_NUCLEOTIDE_SEQUENCE
#
'ATGCGCGGACCAGCAGTCACGACTACGTACGTCAGATCGACTGCTAGCTAGTCAGTCAGTCAGTACGATC'\
'GGCGAGCGACTGGCGAGGGTAGTAGATAGAATAGATGTAGCTGCTAGCTAGTCAGTCAGTCAGTACGATT'
Constants inherited
from Base
Base::NAMESPACE
Bioroebe::ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #file_readlines, #infer_the_namespace, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #namespace?, #no_file_exists_at, #no_newlines, #project_yaml_directory?, #rds, #register_sigint, #return_pwd, #return_the_first_line_of_this_file, #word_wrap, #write_what_into
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #sdir, #set_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
Constructor Details
#initialize(i = DEFAULT_NUCLEOTIDE_SEQUENCE, run_already = true) ⇒ ColourizeSequence
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 37
def initialize(
i = DEFAULT_NUCLEOTIDE_SEQUENCE,
run_already = true
)
reset
set_sequence(i)
if block_given?
yielded = yield
case yielded
when :start_and_stop_codon
@colourize_start_codon_in_this_colour = :turquoise
@colourize_stop_codon_in_this_colour = :orange
else
if yielded.is_a? Hash
if yielded.has_key? :colour_for_the_startcodon
set_colourize_start_codon_in_this_colour(
yielded.delete(:colour_for_the_startcodon)
)
end
end
end
end
case run_already
when :do_not_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
Bioroebe::ColourizeSequence[]
#
251
252
253
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 251
def self.[](i = '')
new(i)
end
|
.return_sequence(i) ⇒ Object
#
Bioroebe::ColourizeSequence.return_sequence
This method can be used to simply return the colourized string rather than display it.
#
239
240
241
242
243
244
245
246
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 239
def self.return_sequence(i)
yielded = yield
_ = self.new(i, :do_not_run_yet) { yielded }
_.do_not_show_the_main_sequence
_.run
colourized_sequence = _.sequence?
return colourized_sequence
end
|
Instance Method Details
#colourize_this_sequence_in_that_colour(sequence, string_to_be_colourized = 'TAA', use_this_colour = @colourize_stop_codon_in_this_colour) ⇒ Object
#
colourize_this_sequence_in_that_colour
#
204
205
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 204
def colourize_this_sequence_in_that_colour(
sequence,
string_to_be_colourized = 'TAA',
use_this_colour = @colourize_stop_codon_in_this_colour
)
if sequence.include? string_to_be_colourized.to_s
sequence.gsub!(/#{string_to_be_colourized}/,
Colours.send(use_this_colour, string_to_be_colourized)+
rev_for_coding_sequence
)
end
end
|
#do_not_show_the_main_sequence ⇒ Object
#
do_not_show_the_main_sequence
#
117
118
119
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 117
def do_not_show_the_main_sequence
@show_sequence = false
end
|
#erev(i) ⇒ Object
220
221
222
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 220
def erev(i)
::Bioroebe.erev(i)
end
|
#modify_sequence ⇒ Object
#
modify_sequence
Before this method is called, the class checks whether colours are used at all.
#
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 134
def modify_sequence
_ = sequence?
if @colourize_start_codon_in_this_colour
colourize_this_sequence_in_that_colour(
_, @use_this_start_codon, @colourize_start_codon_in_this_colour
)
end
if @colourize_stop_codon_in_this_colour
colourize_this_sequence_in_that_colour(_, 'TAG', @colourize_stop_codon_in_this_colour)
colourize_this_sequence_in_that_colour(_, 'TGA', @colourize_stop_codon_in_this_colour)
colourize_this_sequence_in_that_colour(_, 'TAA', @colourize_stop_codon_in_this_colour)
end
end
|
#reset ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 78
def reset
super()
@use_colours = true
@colourize_start_codon_in_this_colour = nil
@colourize_stop_codon_in_this_colour = nil
@show_sequence = true
@use_this_start_codon = 'ATG'
end
|
#rev_for_coding_sequence ⇒ Object
Also known as:
rev
#
rev_for_coding_sequence
#
193
194
195
196
197
198
199
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 193
def rev_for_coding_sequence
::Bioroebe.rev
end
|
#run ⇒ Object
227
228
229
230
231
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 227
def run
modify_sequence if @use_colours
show_sequence if @show_sequence
show_explanation
end
|
#sequence? ⇒ Boolean
Also known as:
input?
124
125
126
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 124
def sequence?
@sequence
end
|
#set_colourize_start_codon_in_this_colour(i) ⇒ Object
#
set_colourize_start_codon_in_this_colour
#
164
165
166
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 164
def set_colourize_start_codon_in_this_colour(i)
@colourize_start_codon_in_this_colour = i
end
|
#set_sequence(i = DEFAULT_NUCLEOTIDE_SEQUENCE) ⇒ Object
#show_explanation ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 171
def show_explanation
if @colourize_start_codon_in_this_colour
e
erev ' Start codon: '+Colours.send(
@colourize_start_codon_in_this_colour,
@use_this_start_codon
)+
rev
e
end
if @colourize_stop_codon_in_this_colour
erev ' Stop codons: '+Colours.send(
@colourize_stop_codon_in_this_colour,
'TAG, TGA, TAA'
)+rev
e
end
end
|
#show_sequence ⇒ Object
157
158
159
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 157
def show_sequence
erev "#{@sequence}#{rev_for_coding_sequence}"
end
|