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?, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #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
Methods included from BaseModule
#absolute_path, #default_file_read, #file_readlines
#internal_hash?, #reset_the_internal_hash
#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_will_we_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?
#infer_the_namespace, #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
74
75
|
# 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[]
#
253
254
255
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 253
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.
#
241
242
243
244
245
246
247
248
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 241
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
#
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 206
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
#
119
120
121
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 119
def do_not_show_the_main_sequence
@show_sequence = false
end
|
#erev(i) ⇒ Object
222
223
224
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 222
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.
#
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 136
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 80
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
#
195
196
197
198
199
200
201
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 195
def rev_for_coding_sequence
::Bioroebe.rev
end
|
#run ⇒ Object
229
230
231
232
233
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 229
def run
modify_sequence if @use_colours
show_sequence if @show_sequence
show_explanation
end
|
#sequence? ⇒ Boolean
Also known as:
input?
126
127
128
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 126
def sequence?
@sequence
end
|
#set_colourize_start_codon_in_this_colour(i) ⇒ Object
#
set_colourize_start_codon_in_this_colour
#
166
167
168
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 166
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 173
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
159
160
161
|
# File 'lib/bioroebe/colours/colourize_sequence.rb', line 159
def show_sequence
erev "#{@sequence}#{rev_for_coding_sequence}"
end
|