Class: Bioroebe::ShowOrf

Inherits:
CommandlineApplication show all
Defined in:
lib/bioroebe/utility_scripts/showorf/showorf.rb

Overview

Bioroebe::ShowOrf

Constant Summary collapse

COLOURIZE_VERTICAL_TOKEN =
#

COLOURIZE_VERTICAL_TOKEN

#
true
LIMIT_AT_N_NUCLEOTIDES =
#

LIMIT_AT_N_NUCLEOTIDES

How many nucleotides we will display per given row.

This should not be a too high value, because it may otherwise overflow into the next line.

#
100
COLOURIZE_STOP_CODONS_IN_RED =
#

COLOURIZE_STOP_CODONS_IN_RED

If true then all ‘*’ will become red.

#
true

Constants inherited from CommandlineApplication

CommandlineApplication::OLD_VERBOSE_VALUE

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Constants inherited from Base

Base::NAMESPACE

Instance Method Summary collapse

Methods inherited from CommandlineApplication

#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, #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

Methods included from CommandlineArguments

#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

Methods included from ColoursForBase

#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

Methods included from InternalHashModule

#internal_hash?, #reset_the_internal_hash

Methods included from InferTheNamespaceModule

#infer_the_namespace, #namespace?

Constructor Details

#initialize(i = ARGV, show_these_frames = [:frame1], run_already = true) ⇒ ShowOrf

#

initialize

The first argument to this method should be the DNA nucleotide string whose ORF you wish to show.

The second argument to this method determines which frames to show.

The class assumes that the first input given is an Array, such as ARGV in particular.

#


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
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 55

def initialize(
    i                 = ARGV,     # The input should be an Array.
    show_these_frames = [:frame1],
    run_already       = true
  )
  reset
  # ======================================================================= #
  # First set up the default frames. This can be overruled lateron,
  # in particular upon the invocation of the method called
  # obtain_commandline_arguments_and_reject_double_separators.
  # ======================================================================= #
  set_show_these_frames(show_these_frames)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when :show_three_frames
      set_show_these_frames(:show_three_frames)
    else
      set_show_these_frames(yielded)
    end
  end
  # ======================================================================= #
  # Next, set the input sequence.
  # ======================================================================= #
  i = obtain_commandline_arguments_and_reject_double_separators(i)
  set_input_sequence(i)
  run if run_already
end

Instance Method Details

#colourize_stop_codons_in_red?Boolean

#

colourize_stop_codons_in_red?

#

Returns:

  • (Boolean)


405
406
407
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 405

def colourize_stop_codons_in_red?
  COLOURIZE_STOP_CODONS_IN_RED
end

#complement(i) ⇒ Object

#

complement

#


576
577
578
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 576

def complement(i)
  ::Bioroebe.complement(i)
end

#default_padding(optional_remove_last_character_n_times = false) ⇒ Object Also known as: pad

#

default_padding (padding tag, pad tag)

#


385
386
387
388
389
390
391
392
393
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 385

def default_padding(
    optional_remove_last_character_n_times = false
  )
  result = '        '.dup
  if optional_remove_last_character_n_times
    optional_remove_last_character_n_times.abs.times { result.chop! }
  end
  return result
end

#frame_1?Boolean Also known as: frame_1, frame1

#

frame_1?

#

Returns:

  • (Boolean)


412
413
414
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 412

def frame_1?
  @frame_1
end

#frame_2?Boolean Also known as: frame_2, frame2

#

frame_2?

#

Returns:

  • (Boolean)


420
421
422
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 420

def frame_2?
  @frame_2
end

#frame_3?Boolean Also known as: frame_3, frame3

#

frame_3?

#

Returns:

  • (Boolean)


428
429
430
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 428

def frame_3?
  @frame_3
end

#hor_bar(i, how_many_times) ⇒ Object

#

hor_bar

This method is used to generate a horizontal bar.

The second argument tells it how many times to repeat the main token.

#


558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 558

def hor_bar(
    i,
    how_many_times
  )
  use_this_token = '-'
  # ======================================================================= #
  # Next, return the assembly.
  # ======================================================================= #
  token_pad+
  use_this_token+
  use_this_token+
  use_this_token+
  (i * how_many_times)
end

#inner_strip(i) ⇒ Object

#

inner_strip

#


252
253
254
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 252

def inner_strip(i)
  i.delete(' ')
end

#input_sequence?Boolean Also known as: input?

#

input_sequence?

#

Returns:

  • (Boolean)


272
273
274
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 272

def input_sequence?
  @input_sequence
end

#max_allowed_size_per_lineObject

#

max_allowed_size_per_line

This method will return a number, which states how many characters are allowed in the main header, above frame 1.

#


450
451
452
453
454
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 450

def max_allowed_size_per_line
  _ = input?
  n_nucleotides = _.size + 2 + _.size.to_s.size
  return n_nucleotides
end
#

menu (menu tag)

By default, the input to this menu will be solely commandline arguments that have ‘–’ as part of their name.

#


673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 673

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === showorf CACAGCAGCAGGCCCTCGGTCGTCGCTCCACATCAGCCGTCACATAGAGCTGATAG --all
    # ===================================================================== #
    when /^-?-?all$/
      set_show_these_frames(:all_frames)
    # ===================================================================== #
    # === showorf CACAGCAGCAGGCCCGTCACATAGAGCTGATAG --frame3
    # ===================================================================== #
    when /^-?-?frame3$/,
         /^-?-?show-?only-?frame-?3$/,
         /^-?-?f3$/
      set_show_these_frames(:f3)
    # ===================================================================== #
    # === showorf --frame2
    # ===================================================================== #
    when /^-?-?frame2$/,
         /^-?-?show-?only-?frame-?2$/,
         /^-?-?f2$/
      set_show_these_frames(:f2)
    # ===================================================================== #
    # === showorf --frames_1_2_3
    # ===================================================================== #
    when /^-?-?frames_?1_?2_?3/,
         /^-?-?show-?frame-?1-?2-?3/
      set_show_these_frames(:f1_and_f2_and_f3)
    # ===================================================================== #
    # === showorf --frame1-and-2
    # ===================================================================== #
    when /^-?-?frame-?1(_|-)?and(_|-)?2/
      set_show_these_frames(:f1_and_f2)
    # ===================================================================== #
    # === showorf --frame1
    # ===================================================================== #
    when /^-?-?frame1$/,
         /-?-?show-?only-?frame-?1/
      set_show_these_frames(:f1)
    # ===================================================================== #
    # === showorf --help
    # ===================================================================== #
    when /help/
      show_help
      exit
    end
  end
end

#n_nucleotides?Boolean

#

n_nucleotides?

#

Returns:

  • (Boolean)


398
399
400
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 398

def n_nucleotides?
  input?.size
end

#obtain_commandline_arguments_and_reject_double_separators(i) ⇒ Object

#

obtain_commandline_arguments_and_reject_double_separators

Presently, we only work on Arrays as input.

#


238
239
240
241
242
243
244
245
246
247
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 238

def obtain_commandline_arguments_and_reject_double_separators(i)
  _ = i
  if i.is_a? Array
    if _.any? {|entry| entry.include? '--' }
      @commandline_arguments = _.select {|line| line.include? '--'}
      _.reject! {|line| line.include? '--'}
    end
  end
  return _
end

#orange_f1Object Also known as: f1

#

orange_f1

#


582
583
584
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 582

def orange_f1
  orange('  F1  ')+rev
end

#orange_f2Object Also known as: f2

#

orange_f2

#


589
590
591
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 589

def orange_f2
  orange('  F2  ')+rev
end

#orange_f3Object Also known as: f3

#

orange_f3

#


596
597
598
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 596

def orange_f3
  orange('  F3  ')+rev
end

#r1Object

#

r1

#


603
604
605
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 603

def r1
  orangered('  R1  ')+rev
end

#r2Object

#

r2

#


610
611
612
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 610

def r2
  orangered('  R2  ')+rev
end

#r3Object

#

r3

#


617
618
619
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 617

def r3
  orangered('  R3  ')+rev
end

#remove_newlines(i) ⇒ Object

#

remove_newlines

This method will simply remove all newlines.

#


281
282
283
284
285
286
287
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 281

def remove_newlines(i)
  if i.is_a? Array
    i.flatten.map {|entry| remove_newlines(entry)}
  else
    i.delete(N)
  end
end

#resetObject

#

reset

#


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 90

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @show_these_frames
  #
  # Specify which frames are to be shown.
  #
  # By default, we will show all 3 forward and all 3 reverse frames.
  #
  # This can change on the commandline. For example,
  # showorf ATGCGC --only-frame-1 would keep only :frame1
  # in this array.  
  # ======================================================================= #
  @show_these_frames = [
    :frame1,
    :frame2,
    :frame3,
    :reverse_frame1,
    :reverse_frame2,
    :reverse_frame3,
  ]
end

#return_horizontal_bar(i = input?) ) ⇒ Object

#

return_horizontal_bar

#


539
540
541
542
543
544
545
546
547
548
549
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 539

def return_horizontal_bar(i = input?)
  _ = return_spacer * i.size
  # ======================================================================= #
  # Next, at every 10th position, replace.
  # ======================================================================= #
  _.gsub!(/----------/, '---------'+return_vertical_token)
  if _.size > LIMIT_AT_N_NUCLEOTIDES
    _ = _[0, LIMIT_AT_N_NUCLEOTIDES]
  end
  return _
end

#return_numbers_based_on_this_input(i) ⇒ Object

#

return_numbers_based_on_this_input

#


355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 355

def return_numbers_based_on_this_input(i)
  _ = ''.dup
  case i.size
  when 11..20
    _ << '10'+pad
  when 21..29
    _ << '10'+pad+'20'+pad
  when 30..39
    _ << '10'+pad+'20'+pad+'30'+pad
  when 40..49
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad
  when 50..59
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad+'50'+pad
  when 60..69
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad+'50'+pad+'60'+pad
  when 70..79
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad+'50'+pad+'60'+pad+'70'+pad
  when 80..89
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad+'50'+pad+'60'+pad+'70'+pad+'80'+pad
  when 90..99
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad+'50'+pad+'60'+pad+'70'+pad+'80'+pad+'90'+pad
  else
    _ << '10'+pad+'20'+pad+'30'+pad+'40'+pad+'50'+pad+'60'+pad+'70'+pad+'80'+pad+'90'+pad(-1)+'100'+pad
  end
  return _ # Return it here.
end

#return_properly_formated_spacer_tokens(i) ⇒ Object

#

return_properly_formated_spacer_tokens

Input how many ‘-’ tokens you need to have for this line.

#


531
532
533
534
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 531

def return_properly_formated_spacer_tokens(i)
  _ = return_spacer(i)
  _.gsub(/----------/, '---------'+return_vertical_token)
end

#return_spacer(n_spacer_tokens = 100) ⇒ Object

#

return_spacer

#


334
335
336
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 334

def return_spacer(n_spacer_tokens = 100)
  '-' * n_spacer_tokens.abs
end

#return_vertical_tokenObject

#

return_vertical_token

If we want to return a colourized ‘|’ token.

#


438
439
440
441
442
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 438

def return_vertical_token
  _ = '|'
  _ = palegreen(_)+rev if COLOURIZE_VERTICAL_TOKEN
  return _
end

#reverse_complement(i) ⇒ Object

#

reverse_complement

#


348
349
350
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 348

def reverse_complement(i)
  i = complement(i.reverse)
end

#runObject

#

run (run tag)

#


729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 729

def run
  menu
  _ = input?.dup # Keep a pointer to the input given to us.
  n_nucleotides = _.size.to_s
  # ======================================================================= #
  # Chop the main string up into chunks of 100 each.
  # ======================================================================= #
  chopped_input = _.scan(/.{1,100}/m)
  converted_sequence_for_frame_1 = to_frame1(_)
  converted_sequence_for_frame_2 = to_frame2(_)
  converted_sequence_for_frame_3 = to_frame3(_)
  converted_sequence_for_reverse_frame_1 = to_reverse_frame1(_)
  converted_sequence_for_reverse_frame_2 = to_reverse_frame2(_)
  converted_sequence_for_reverse_frame_3 = to_reverse_frame3(_)
  e
  e "#{rev}Translation of requested code (5' #{steelblue('')} #{rev}3') "\
    "for #{simp(n_nucleotides)}#{rev} nucleotides.#{N}"
  e
  # ======================================================================= #
  # Next, we build up the 3 different frames. In order to do so,
  # we will first insert two ' ' after every position.
  # ======================================================================= #
  converted_sequence_for_frame_1 = converted_sequence_for_frame_1.chars.map {|entry|
    entry+'  '
  }.join
  converted_sequence_for_frame_2 = ' '+converted_sequence_for_frame_2.chars.map {|entry|
    entry+'  '
  }.join
  converted_sequence_for_frame_3 = '  '+converted_sequence_for_frame_3.chars.map {|entry|
    entry+'  '
  }.join
  converted_sequence_for_reverse_frame_1 = converted_sequence_for_reverse_frame_1.chars.map {|entry|
    entry+'  '
  }.join
  converted_sequence_for_reverse_frame_2 = ' '+converted_sequence_for_reverse_frame_2.chars.map {|entry|
    entry+'  '
  }.join
  converted_sequence_for_reverse_frame_3 = '  '+converted_sequence_for_reverse_frame_3.chars.map {|entry|
    entry+'  '
  }.join
  # ======================================================================= #
  # We will chop them up into runs of 100, but only display
  # for how many we get. The seagreen bar is on the very top,
  # the "10    20" and so on.
  # ======================================================================= #
  e '                    '+
    seagreen(
      return_numbers_based_on_this_input(_)
    )+
    rev
  # ======================================================================= #
  # === Get rid of newlines
  # ======================================================================= #
  if chopped_input.any? {|entry| entry.include? N }
    chopped_input = remove_newlines(chopped_input)
  end
  chopped_input = strip(chopped_input)
  chopped_input.each_with_index {|aminoacids_in_this_line, index|

    left_nucleotide_position = ((index * 100)+1).to_s.rjust(3)
    right_position = ((100 * index)+aminoacids_in_this_line.size).to_s

    # ===================================================================== #
    # Return the properly formated spacer tokens next. We need to find
    # out how many tokens we have to display.
    # ===================================================================== #
    display_n_tokens = (right_position.to_i+1 - left_nucleotide_position.strip.to_i)

    # ===================================================================== #
    # Display the first frame next, then the other two frames.
    # ===================================================================== #
    set_frame_1(
      converted_sequence_for_frame_1[(100 * index)..((100 * index)+100-1)]
    ) if show_frame_1?

    set_frame_2(
      converted_sequence_for_frame_2[(100 * index)..((100 * index)+100-1)]
    ) if show_frame_2?

    set_frame_3(
      converted_sequence_for_frame_3[(100 * index)..((100 * index)+100-1)]
    ) if show_frame_3?
    # ===================================================================== #
    # Next add the '----|' separators.
    # ===================================================================== #
    e "           #{return_properly_formated_spacer_tokens(display_n_tokens)}"
    # ===================================================================== #
    # === Next show the main nucleotide sequence
    # ===================================================================== #
    e '      '+
      mediumspringgreen(left_nucleotide_position)+rev+
      '  '+
      mediumseagreen(aminoacids_in_this_line.upcase)+rev+'  '+
      mediumspringgreen( # <- This here is the end-part that is colourized.
        ((100 * index)+aminoacids_in_this_line.size).to_s
      )
    # ===================================================================== #
    # The number should be reset after a '*' character.
    # ===================================================================== #

    # ===================================================================== #
    # === Handle Frame1 next
    # ===================================================================== #
    if show_frame_1?
      show_this_frame(frame_1, :frame1)
    end

    # ===================================================================== #
    # === Handle Frame2
    # ===================================================================== #
    if show_frame_2?
      show_this_frame(frame_2, :frame2)
    end

    # ===================================================================== #
    # === Handle Frame3
    # ===================================================================== #
    if show_frame_3?
      show_this_frame(frame_3, :frame3)
    end

    # ===================================================================== #
    # Next, consider showing the reverse frames.
    # ===================================================================== #
    if show_reverse_frame_1?
      e r1+'     '+converted_sequence_for_reverse_frame_1
    end

    if show_reverse_frame_2?
      e r2+'     '+converted_sequence_for_reverse_frame_2
    end

    if show_reverse_frame_3?
      e r3+'     '+converted_sequence_for_reverse_frame_3
    end

    e
  }
end

#set_frame_1(i) ⇒ Object

#

set_frame_1

#


303
304
305
306
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 303

def set_frame_1(i)
  i = i.to_s
  @frame_1 = i
end

#set_frame_2(i) ⇒ Object

#

set_frame_2

#


311
312
313
314
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 311

def set_frame_2(i)
  i = i.to_s
  @frame_2 = i
end

#set_frame_3(i) ⇒ Object

#

set_frame_3

#


319
320
321
322
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 319

def set_frame_3(i)
  i = i.to_s
  @frame_3 = i
end

#set_input_sequence(i) ⇒ Object

#

set_input_sequence

Set the DNA sequence here.

#


261
262
263
264
265
266
267
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 261

def set_input_sequence(i)
  i = i.join if i.is_a? Array
  i = remove_newlines(i)
  i = strip(i) # Get rid of trailing thingies.
  i = inner_strip(i)
  @input_sequence = i
end

#set_show_these_frames(i) ⇒ Object

#

set_show_these_frames

#


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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 117

def set_show_these_frames(i)
  case i # case tag
  # ======================================================================= #
  # === frame1
  # ======================================================================= #
  when :frame1,
       :f1
    @show_these_frames = [:frame1]
  # ======================================================================= #
  # === frame2
  # ======================================================================= #
  when :frame2,
       :f2
    @show_these_frames = [:frame2]
  # ======================================================================= #
  # === frame3
  # ======================================================================= #
  when :frame3,
       :f3
    @show_these_frames = [:frame3]
  # ======================================================================= #
  # === frame1_frame
  # ======================================================================= #
  when :frame1_frame2,
       :f1_and_f2
    @show_these_frames = [:frame1, :frame2]
  # ======================================================================= #
  # === f1_and_f2_and_f3
  # ======================================================================= #
  when :f1_and_f2_and_f3
    @show_these_frames = [:frame1, :frame2, :frame3]
  # ======================================================================= #
  # === all_frames                                                (all tag)
  #
  # Use this when you wish to show all 6 reading frames.
  # ======================================================================= #
  when :all_frames,
       :show_three_frames,
       :frame1_frame2_frame3,
       :frame1_frame2_frame2_reverse1_reverse2_reverse3
    @show_these_frames = [
      :frame1,
      :frame2,
      :frame3,
      :reverse_frame1,
      :reverse_frame2,
      :reverse_frame3
    ]
  end
end

#show_frame_1?Boolean

#

show_frame_1?

#

Returns:

  • (Boolean)


194
195
196
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 194

def show_frame_1?
  @show_these_frames.include? :frame1
end

#show_frame_2?Boolean

#

show_frame_2?

#

Returns:

  • (Boolean)


201
202
203
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 201

def show_frame_2?
  @show_these_frames.include? :frame2
end

#show_frame_3?Boolean

#

show_frame_3?

#

Returns:

  • (Boolean)


208
209
210
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 208

def show_frame_3?
  @show_these_frames.include? :frame3
end

#show_helpObject

#

show_help (help tag)

Invocation example:

showorf --help
#


175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 175

def show_help
  e
  opnerev 'This class is capable of showing the ORF (open '\
             'reading frame) from the'
  opnerev 'given input string (which is assumed to be a '\
             'nucleotide sequence).'
  e
  opnerev 'By default, this class will show all 3 reading frames, but'
  opnerev 'you can also selectively show only one frame. Examples:'
  e
  opnerev '  --frame1 # show reading frame1 (forward frame 1)'
  opnerev '  --frame2 # show reading frame1 (forward frame 2)'
  opnerev '  --frame3 # show reading frame1 (forward frame 3)'
  e
end

#show_reverse_frame_1?Boolean

#

show_reverse_frame_1?

#

Returns:

  • (Boolean)


215
216
217
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 215

def show_reverse_frame_1?
  @show_these_frames.include? :reverse_frame1
end

#show_reverse_frame_2?Boolean

#

show_reverse_frame_2?

#

Returns:

  • (Boolean)


222
223
224
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 222

def show_reverse_frame_2?
  @show_these_frames.include? :reverse_frame2
end

#show_reverse_frame_3?Boolean

#

show_reverse_frame_3?

#

Returns:

  • (Boolean)


229
230
231
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 229

def show_reverse_frame_3?
  @show_these_frames.include? :reverse_frame3
end

#show_this_frame(i = frame_1, which_frame = :frame1) ⇒ Object

#

show_this_frame

#


624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 624

def show_this_frame(
    i           = frame_1,
    which_frame = :frame1
  )
  _ = max_allowed_size_per_line
  n_aminoacids = i.delete(' ').chars.size.to_s
  right_padding = '  '.dup
  case which_frame
  when :frame1
    which_frame = orange_f1
    right_padding << '  '
  when :frame2
    which_frame = orange_f2
    right_padding << ' '
  when :frame3
    which_frame = orange_f3
  end
  leading_part = which_frame+(' ' * 3)+'  '+i
  # ======================================================================= #
  # === Colourize stop codons in the colour red
  # ======================================================================= #
  if colourize_stop_codons_in_red? and use_colours?
    leading_part.gsub!(/(\*)/, swarn('\\1')+rev)
  end
  leading_part << right_padding
  # ======================================================================= #
  # We may have to modify the variable n_aminoacids if there is a stop
  # codon.
  # ======================================================================= #
  if i.include? '*'
    n_aminoacids = i[(i.rindex('*')+1) .. i.size].delete(' ').size.to_s.
                   rjust(i.size.to_s.size)
  end
  # ======================================================================= #
  # Next also append how many aminoacids are part of this squence:
  # ======================================================================= #
  string = leading_part+
           darkolivegreen(
             n_aminoacids.to_s+' aminoacids'
           )+rev
  e string
end

#strip(i) ⇒ Object

#

strip

#


292
293
294
295
296
297
298
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 292

def strip(i)
  if i.is_a? Array
    i.map {|entry| strip(entry) }
  else
    i.strip
  end
end

#to_frame1(i) ⇒ Object

#

to_frame1

Frame1 requires no change, so we can simply pass it into the method Bioroebe.translate_dna_into_aminoacid().

#


462
463
464
465
466
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 462

def to_frame1(i)
  return ::Bioroebe.translate_dna_into_aminoacid(
    i
  ) # We need the module-method here.
end

#to_frame2(i) ⇒ Object

#

to_frame2

Frame2 requires a change, hence the second line in the method body.

#


473
474
475
476
477
478
479
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 473

def to_frame2(i)
  i = i.dup
  i[0,1] = '' # Chop off the first character.
  return ::Bioroebe.translate_dna_into_aminoacid(
    i
  )
end

#to_frame3(i) ⇒ Object

#

to_frame3

Frame3 requires a change.

#


486
487
488
489
490
491
492
493
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 486

def to_frame3(i)
  i = i.dup
  i[0,1] = '' # Chop off the first character.
  i[0,1] = '' # And again.
  return ::Bioroebe.translate_dna_into_aminoacid(
    i
  )
end

#to_reverse_frame1(i) ⇒ Object

#

to_reverse_frame1

#


506
507
508
509
510
511
512
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 506

def to_reverse_frame1(i)
  i = reverse_complement(i).dup
  i[0,1] = ''
  return ::Bioroebe.translate_dna_into_aminoacid(
    i
  )
end

#to_reverse_frame2(i) ⇒ Object

#

to_reverse_frame2

#


517
518
519
520
521
522
523
524
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 517

def to_reverse_frame2(i)
  i = reverse_complement(i).dup
  i[0,1] = ''
  i[0,1] = ''
  return ::Bioroebe.translate_dna_into_aminoacid(
    i
  )
end

#to_reverse_frame3(i) ⇒ Object

#

to_reverse_frame3

#


498
499
500
501
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 498

def to_reverse_frame3(i)
  i = reverse_complement(i).dup
  return ::Bioroebe.translate_dna_into_aminoacid(i)
end

#token_padObject

#

token_pad

#


341
342
343
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 341

def token_pad
  '--------' # Horizontal padding.
end

#total_length?Boolean Also known as: total_size?

#

total_length?

#

Returns:

  • (Boolean)


327
328
329
# File 'lib/bioroebe/utility_scripts/showorf/showorf.rb', line 327

def total_length?
  input?.size
end