Class: Bioroebe::DnaToAminoacidSequence
Overview
Bioroebe::DnaToAminoacidSequence
Constant Summary
collapse
- DEFAULT_RUN_MODE =
true
CommandlineApplication::OLD_VERBOSE_VALUE
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Constants inherited
from Base
Base::NAMESPACE
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === Bioroebe::DnaToAminoacidSequence[] ========================================================================= #.
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, #opnerev, #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, #runmode?, #set_be_verbose, #set_runmode, #start_codon?, #stop_codons?, #strict_filter_away_invalid_aminoacids, #taxonomy_download_directory?, #three_to_one, #to_rna, #trailing_three_prime, #use_opn?, #verbose_truth, #was_or_were, #without_extname, #write_what_into
Methods included from BaseModule
#absolute_path, #default_file_read, #file_readlines
#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, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_will_we_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?, #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
#internal_hash?, #reset_the_internal_hash
#infer_the_namespace, #namespace?
Constructor Details
#initialize(commandline_arguments = nil, run_already = DEFAULT_RUN_MODE) ⇒ DnaToAminoacidSequence
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 53
def initialize(
commandline_arguments = nil,
run_already = DEFAULT_RUN_MODE
)
reset
set_commandline_arguments(
commandline_arguments
)
if block_given?
yielded = yield
case yielded
when :be_verbose
set_be_verbose
when :be_quiet
be_quiet
end
end
case run_already when :frame_two,
:two
set_use_frame_number(:two)
run_already = DEFAULT_RUN_MODE
when :frame_three,
:three
set_use_frame_number(:three)
run_already = DEFAULT_RUN_MODE
when :be_quiet_and_no_colours_and_no_output,
:return_silently
be_quiet
disable_colours
no_output
run_already = DEFAULT_RUN_MODE
when :be_quiet_and_no_colours
be_quiet
disable_colours
run_already = DEFAULT_RUN_MODE
when :be_quiet
be_quiet
run_already = DEFAULT_RUN_MODE
when :do_not_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
Bioroebe::DnaToAminoacidSequence[]
#
636
637
638
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 636
def self.[](i = ARGV)
new(i) { :be_quiet }.result
end
|
Instance Method Details
#be_quiet ⇒ Object
218
219
220
221
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 218
def be_quiet
set_be_quiet
@internal_hash[:report_result] = false
end
|
#be_quiet_and_no_colours ⇒ Object
#
be_quiet_and_no_colours
#
226
227
228
229
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 226
def be_quiet_and_no_colours
be_quiet
disable_colours
end
|
#colourize_stop_codons? ⇒ Boolean
#
colourize_stop_codons?
#
190
191
192
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 190
def colourize_stop_codons?
@internal_hash[:colourize_stop_codons]
end
|
#do_report_the_reading_frame(i = @result) ⇒ Object
#
do_report_the_reading_frame
This method will, with colours, output the full reading frame.
#
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 344
def do_report_the_reading_frame(
i = @result
)
if show_as_three_letter_aminoacid_sequence?
i = one_to_three(i)
end
if use_a_spacer_between_the_aminoacids?
splitted = i.split(//)
i = splitted.join('-')
end
result = "#{lightgreen(i)}#{rev}"
if colourize_stop_codons? and result.include?('*')
result = result.dup if result.frozen?
result.gsub!(
/\*/,
orchid('*')+
remove_trailing_ansii_escape_code(lightgreen(''))
)
end
set_result(result)
if report_result? and be_verbose?
if show_ruler? e " #{Bioroebe.return_ruler(i)}"
end
e " #{@result}"
e N
end
end
|
#do_show_as_the_three_letter_aminoacid_sequence ⇒ Object
#
do_show_as_the_three_letter_aminoacid_sequence
#
197
198
199
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 197
def do_show_as_the_three_letter_aminoacid_sequence
@internal_hash[:show_as_three_letter_aminoacid_sequence] = true
end
|
#do_show_ruler ⇒ Object
613
614
615
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 613
def do_show_ruler
@internal_hash[:show_ruler] = true
end
|
318
319
320
321
322
323
324
325
326
327
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 318
def (
i = @use_frame_number
)
e
coloured_frame = palegreen(
'frame-'+one_two_or_three(i)
)+rev
e "#{rev}The #{coloured_frame}#{rev} sequence is: (#{sequence?.size} aminoacids)"
e
end
|
#do_the_conversion_step ⇒ Object
#
do_the_conversion_step
This method will do the actual DNA-to-aminoacid conversion step.
Make sure that the correct reading frame has been “selected” before calling this method.
#
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 533
def do_the_conversion_step
::Bioroebe.load_the_codon_table_dataset(@use_the_codon_table_for)
_ = ensure_DNA_sequence(
commandline_arguments?.join(' ').strip.dup.
delete(' ').
delete('|'). delete('-') )
if _ and _.include?('.') and File.file?(_)
_ = File.read(_).strip end
if _ =~ /\d+/ _.delete!('[0-9]')
end
case @use_frame_number
when :frame_two
_[0,1] = ''
when :frame_three
_[0,2] = ''
end
unless _
erev 'Please supply a sequence to this class.'
exit
end
splitted = _.scan(/.../)
@result = ''.dup
splitted.each {|this_codon|
translated_codon = translate_dna_into_aminoacid(this_codon).to_s
@result << translated_codon
if @stop_at_the_first_stop_codon and (translated_codon == '*')
break
end
}
end
|
#ensure_DNA_sequence(i) ⇒ Object
587
588
589
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 587
def ensure_DNA_sequence(i)
return i.tr('U','T')
end
|
#
These are the registered commandline arguments for this class.
We will act only on arguments given to this method, staring with two hyphens (aka –).
#
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 413
def (
i = return_commandline_arguments_starting_with_two_hyphens
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i
when /^-?-?3(-|_| )?spacer$/i,
/^-?-?spacer$/i
@internal_hash[:use_a_spacer_between_the_aminoacids] = true
when /^-?-?three(-|_| )?letter$/i
do_show_as_the_three_letter_aminoacid_sequence
when /^-?-?ruler$/i
do_show_ruler
when /^-?-?help$/i
show_help
exit
when /^-?-?gui$/i
require 'bioroebe/gui/gtk3/dna_to_aminoacid_widget/dna_to_aminoacid_widget.rb'
::Bioroebe::GUI::Gtk::DnaToAminoacidWidget.run
exit
when /^-?-?stop(-|_| )?at(-|_| )?the(-|_| )?first(-|_| )?stop(-|_| )?codon$/i
@stop_at_the_first_stop_codon = true
when /^-?-?frame(\d{1})$/i
set_use_this_reading_frame($1.to_s.dup)
when /^-?-?use(-|_| )?this(-|_| )?codon(-|_| )?table=(.+)$/i _ = $4.to_s.dup.to_sym
set_use_the_codon_table_for(_)
end
end
end
|
#no_output ⇒ Object
300
301
302
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 300
def no_output
@internal_hash[:report_result] = false
end
|
#one_two_or_three(i) ⇒ Object
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 234
def one_two_or_three(i)
case i
when :frame_one
'1'
when :frame_two
'2'
when :frame_three
'3'
end
end
|
#report ⇒ Object
332
333
334
335
336
337
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 332
def report
if be_verbose?
(@use_frame_number)
end
do_report_the_reading_frame
end
|
#report_result? ⇒ Boolean
293
294
295
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 293
def report_result?
@internal_hash[:report_result]
end
|
#reset ⇒ Object
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
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 128
def reset
super()
set_use_frame_number(:one) @internal_hash[:use_a_spacer_between_the_aminoacids] = false
@codon_table_dataset = ::Bioroebe.codon_table_dataset?
@stop_at_the_first_stop_codon = false
@result = nil
@use_the_codon_table_for = :humans
@internal_hash[:report_result] = true
@internal_hash[:show_ruler] = false
@internal_hash[:show_as_three_letter_aminoacid_sequence] = false
@internal_hash[:colourize_stop_codons] = true
end
|
#result? ⇒ Boolean
Also known as:
result, input_sequence?, seq?, sequence?, sequence
#
result?
This variable will hold the translated sequence ready, e. g. the aminoacid sequence.
#
385
386
387
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 385
def result?
@result
end
|
#run ⇒ Object
627
628
629
630
631
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 627
def run
do_the_conversion_step
report
end
|
#set_result(i) ⇒ Object
Also known as:
use_this_sequence, use_this_sequence=, set_sequence
307
308
309
310
311
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 307
def set_result(i)
i = i.join if i.is_a? Array
i.delete!('|') if i.include? '|'
@result = i
end
|
#set_use_frame_number(i = :default) ⇒ Object
Also known as:
use_this_reading_frame=, set_use_this_reading_frame
#
set_use_frame_number
Designate which frame is to be used through this method. By default it will be frame number 1.
#
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 260
def set_use_frame_number(
i = :default
)
case i
when :one,
:default,
'1'
i = :frame_one
when :two,
'2'
i = :frame_two
when :three,
'3'
i = :frame_three
end
@use_frame_number = i
end
|
#set_use_the_codon_table_for(i) ⇒ Object
#
set_use_the_codon_table_for
#
211
212
213
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 211
def set_use_the_codon_table_for(i)
@use_the_codon_table_for = i
end
|
#show_as_three_letter_aminoacid_sequence? ⇒ Boolean
#
show_as_three_letter_aminoacid_sequence?
#
204
205
206
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 204
def show_as_three_letter_aminoacid_sequence?
@internal_hash[:show_as_three_letter_aminoacid_sequence]
end
|
#show_help ⇒ Object
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 594
def show_help
e 'Available options:'
e
e ' --gui # start the GUI'
e ' --stop-at-the-first-stop-codon # stop at the first stop codon encountered'
e ' --frame1 # show the first frame translation only'
e ' --frame2 # show the second frame translation only'
e ' --frame3 # show the third frame translation only'
e ' --use-this-codon-table=bacteria # specify a specific codon table '\
'(in this case bacteria)'
e ' --three-letter # show the three letter amino acid code'
e ' --ruler # show a helpful ruler on top '\
'of the sequence'
e
end
|
#show_ruler? ⇒ Boolean
620
621
622
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 620
def show_ruler?
@internal_hash[:show_ruler]
end
|
#translate_dna_into_aminoacid(i) ⇒ Object
#
translate_dna_into_aminoacid
This method will perform the lookup onto the hash (codon table dataset), in order to find the corresponding aminoacid.
#
399
400
401
402
403
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 399
def translate_dna_into_aminoacid(i)
@codon_table_dataset[
i.tr('U','T')
]
end
|
#use_a_spacer_between_the_aminoacids? ⇒ Boolean
#
use_a_spacer_between_the_aminoacids?
#
183
184
185
|
# File 'lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb', line 183
def use_a_spacer_between_the_aminoacids?
@internal_hash[:use_a_spacer_between_the_aminoacids]
end
|