Class: Bioroebe::ShowThisCodonTable
Constant Summary
collapse
- LPAD =
' '
- MPAD =
' '
- CYAN =
Colours::CYAN
- CYAN_U =
CYAN+'U'
- CYAN_A =
CYAN+'A'
- CYAN_G =
CYAN+'G'
- CYAN_C =
CYAN+'C'
- ARRAY_ALL_CODONS =
#
CodonTable::ARRAY_ALL_CODONS (array tag)
This Array will be used to batch-define the necessary methods.
#
%w(
TTT? TTC? TTA? TTG?
TCT? TCC? TCA? TCG?
TAT? TAC? TAA? TAG?
TGT? TGC? TGA? TGG?
CTT? CCT? CAT? CGT?
CTC? CCC? CAC? CGC?
CTA? CCA? CAA? CGA?
CTG? CCG? CAG? CGG?
ATT? ACT? AAT? AGT?
ATC? ACC? AAC? AGC?
ATA? ACA? AAA? AGA?
ATG? ACG? AAG? AGG?
GTT? GCT? GAT? GGT?
GTC? GCC? GAC? GGC?
GTA? GCA? GAA? GGA?
GTG? GCG? GAG? GGG?
)
- STOP =
Colours::RED+'STOP'+Colours::GREEN
- DEFAULT_CODON_TABLE_TO_USE =
#
DEFAULT_CODON_TABLE_TO_USE
#
:human
CommandlineApplication::OLD_VERBOSE_VALUE
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Constants inherited
from Base
Base::NAMESPACE
Instance Method Summary
collapse
#all_aminoacids?, #append_what_into, #at_home?, #be_silent, #be_verbose?, #cat, #ccliner, #change_directory, #cliner, #codon_table_dataset?, #codon_to_aminoacid, #codons_for?, #colourize_this_dna_sequence, #complement, #cp, #disable_warnings, #download_dir?, #editor?, #enable_warnings, #ensure_that_the_base_directories_exist, #esystem, #extract, #is_this_a_start_codon?, #is_this_a_stop_codon?, #leading_five_prime, #load_bioroebe_yaml_file, #log_directory?, #one_letter_to_long_name, #one_to_three, #only_numbers?, #open_in_browser, #opne, #opnn, #pad_with_double_quotes, #pad_with_single_quotes, #partner_nucleotide, #remove_numbers, #remove_trailing_ansii_escape_code, #return_all_possible_start_codons, #return_array_of_one_letter_aminoacids, #return_cheerful_person, #return_chunked_display, #return_ubiquitin_sequence, #set_be_verbose, #start_codon?, #stop_codons?, #strict_filter_away_invalid_aminoacids, #taxonomy_download_directory?, #three_to_one, #to_rna, #trailing_three_prime, #use_opn?, #was_or_were, #without_extname, #write_what_into
#commandline_arguments?, #commandline_arguments_that_are_files?, #e, #first?, #first_non_hyphen_argument?, #remove_hyphens_from_the_commandline_arguments, #return_commandline_arguments_as_string, #return_commandline_arguments_that_are_not_files, #return_entries_without_two_leading_hyphens, #select_commandline_arguments, #select_entries_starting_with_two_hyphens, #set_commandline_arguments
#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #egold, #enable_colours, #eorange, #eparse, #erev, #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?
Methods inherited from Base
#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #file_readlines, #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, #write_what_into
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ ShowThisCodonTable
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 99
def initialize(
commandline_arguments = ARGV,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Instance Method Details
#colourized_line(i) ⇒ Object
345
346
347
348
349
350
351
352
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 345
def colourized_line(i)
result = i.dup.gsub(/\*/, stop?).
gsub(/START/, '*').
squeeze('*').
gsub(/\*/,tomato('*')+rev)
e result
i
end
|
#consider_using_a_specific_codon_table(i = first_argument?)
) ⇒ Object
#
consider_using_a_specific_codon_table
#
206
207
208
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 206
def consider_using_a_specific_codon_table(i = first_argument?)
set_use_this_codon_table(i)
end
|
#cyan ⇒ Object
199
200
201
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 199
def cyan
CYAN end
|
#cyana ⇒ Object
Also known as:
cyan_a, cyan_A
183
184
185
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 183
def cyana
cyan+'A'+rev
end
|
#cyanc ⇒ Object
Also known as:
cyan_c, cyan_C
486
487
488
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 486
def cyanc
cyan+'C'+rev
end
|
#cyang ⇒ Object
Also known as:
cyan_g, cyan_G
191
192
193
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 191
def cyang
cyan+'G'+rev
end
|
#cyanu ⇒ Object
Also known as:
cyan_U, cyan_u, cyan_T
#
cyanu
This will either show a U or a T.
#
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 466
def cyanu
case @show_rna_or_dna
when :rna
"#{cyan}U#{rev}"
when :dna
"#{cyan}T#{rev}"
end
end
|
#determine_all_codon_methods(dataset = dataset?
) ⇒ Object
#
determine_all_codon_methods
Dynamically define the proper methods.
#
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 303
def determine_all_codon_methods(
dataset = dataset?
)
start_codons = dataset['START']
if start_codons.include? '|'
start_codons = start_codons.split('|').map(&:strip)
end
if @autogenerate_codon_related_methods
dataset = dataset?
ARRAY_ALL_CODONS.each {|entry|
entry = entry.to_sym
unless self.respond_to? entry
self.class.instance_eval {
define_method(entry) {
name_of_the_codon = __method__.to_s.chop
if dataset.has_key? name_of_the_codon
result = dataset.fetch(name_of_the_codon)
result = stop? if result == '*'
if start_codons.include? name_of_the_codon
result << 'START'
end
else
result = 'UNKNOWN (from '+name_of_the_codon+')'
end
return result
}
}
end
}
@autogenerate_codon_related_methods = false
end
end
|
#determine_dataset ⇒ Object
#
determine_dataset
This method will determine the correct codon-dataset. It has to make sure that the codon table actually exists, though.
#
430
431
432
433
434
435
436
437
438
439
440
441
442
443
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 430
def determine_dataset
if title?.nil? and first_argument?.nil?
set_title("Standard (Eukaryote) Codon Table")
set_codon_table(1)
end
this_codon_table = use_which_codon_table?
if this_codon_table.is_a?(String) and (this_codon_table =~ /^\d+$/)
title = ::Bioroebe::CodonTables.definitions?[this_codon_table.to_i]
set_title(title)
end
end
|
#display_title ⇒ Object
#
display_title
This method will show the title of the codon table in question.
#
416
417
418
419
420
421
422
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 416
def display_title
title = title?
if title
erev title+' (codon table number: '+
steelblue(codon_table?.to_s)+rev+'):'
end
end
|
#green ⇒ Object
Also known as:
rev
169
170
171
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 169
def green
Colours::GREEN
end
|
#is_this_codon_table_available?(i) ⇒ Boolean
#
is_this_codon_table_available?
#
213
214
215
216
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 213
def is_this_codon_table_available?(i)
target = directory_to_the_codon_tables?+"#{i}.yml"
return File.exist?(target)
end
|
#left_pad ⇒ Object
515
516
517
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 515
def left_pad
print ' '
end
|
#lpad(i) ⇒ Object
221
222
223
224
225
226
227
228
229
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 221
def lpad(i)
if i.include? 'STOP'
i+' '
elsif i.include? 'START'
i+' '
else
i+' '
end
end
|
#lpad? ⇒ Boolean
234
235
236
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 234
def lpad?
LPAD
end
|
#lpad_on(*i) ⇒ Object
#
lpad_on
This method combines several calls such as this:
lpad(TTC?)+lpad(TCC?)+lpad(TAC?)+lpad(TGC?)
It was too long, so it was changed to.
lpad_on(TTT?, TCT?, TAT?, TGT?)
#
294
295
296
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 294
def lpad_on(*i)
i.map {|entry| lpad(entry) }.join
end
|
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 357
def (
i = @commandline_arguments
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?rna$/i
@show_rna_or_dna = :rna
@commandline_arguments.reject! {|entry| entry.to_s =~ /^-?-?rna$/i }
else
if i.to_s =~ /^(\d{1,2})-(\d{1,2})$/
$1.to_i.upto($2.to_i) {|n|
consider_using_a_specific_codon_table(n)
determine_dataset
determine_all_codon_methods
display_codon_table
}
exit
elsif i.to_s =~ /^\d{1,2}$/
require 'bioroebe/codons/codon_tables.rb'
@commandline_arguments[0] = i.to_i
set_title(
Bioroebe::CodonTables.title_for_entry_number?(i.to_i)
)
end
end
end
end
|
#notify_the_user_that_no_such_codon_table_could_be_found ⇒ Object
#
notify_the_user_that_no_such_codon_table_could_be_found
#
448
449
450
451
452
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 448
def notify_the_user_that_no_such_codon_table_could_be_found
erev 'No codon table matching this input ('+
steelblue(first_argument?.to_s)+
rev+') could be found.'
end
|
#reset ⇒ Object
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
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 113
def reset
super()
@internal_hash = {}
@internal_hash[:title] = nil
@is_available = false
@show_rna_or_dna = :dna
@autogenerate_codon_related_methods = true
end
|
#return_dataset_from_codon_table(this_codon_table = use_which_codon_table?
) ⇒ Object
#
return_dataset_from_codon_table
This method will return the dataset from the codon table.
#
258
259
260
261
262
263
264
265
266
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 258
def return_dataset_from_codon_table(
this_codon_table = use_which_codon_table?
)
if this_codon_table.is_a?(String) and (this_codon_table =~ /^\d+$/)
this_codon_table = this_codon_table.to_i
set_codon_table(this_codon_table)
end
::Bioroebe.codon_table_dataset?
end
|
#run ⇒ Object
556
557
558
559
560
561
562
563
564
565
566
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 556
def run
consider_using_a_specific_codon_table
determine_dataset
determine_all_codon_methods
if @is_available
display_codon_table
else
notify_the_user_that_no_such_codon_table_could_be_found
end
end
|
#set_codon_table(i) ⇒ Object
271
272
273
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 271
def set_codon_table(i)
::Bioroebe.set_codon_table(i)
end
|
#set_title(i = nil) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 149
def set_title(
i = nil
)
if i and i.is_a?(String)
i = i.dup if i.frozen?
i << ' Codon Table' unless i.end_with?(' Codon Table')
end
@internal_hash[:title] = i
end
|
#set_use_this_codon_table(i = DEFAULT_CODON_TABLE_TO_USE) ⇒ Object
#
set_use_this_codon_table
This will initially hold the codon table internally.
#
#stop? ⇒ Boolean
176
177
178
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 176
def stop?
STOP
end
|
#title? ⇒ Boolean
278
279
280
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 278
def title?
@internal_hash[:title]
end
|
457
458
459
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 457
def
e cyan+N+LPAD+' '+cyanu+MPAD+cyanc+MPAD+cyana+MPAD+cyang
end
|
#use_this_codon_table? ⇒ Boolean
Also known as:
use_which_codon_table?, codon_table?
#
use_this_codon_table?
#
241
242
243
|
# File 'lib/bioroebe/codons/show_this_codon_table.rb', line 241
def use_this_codon_table?
::Bioroebe.codon_table?
end
|