Class: Bioroebe::GenbankFlatFileFormatGenerator

Inherits:
CommandlineApplication show all
Defined in:
lib/bioroebe/genbank/genbank_flat_file_format_generator.rb

Overview

Bioroebe::GenBankFlatFileFormatGenerator

Constant Summary collapse

DEFAULT_NAME_OF_THE_LOCUS =
#

DEFAULT_NAME_OF_THE_LOCUS

#
'tmpseq_0'

Constants inherited from CommandlineApplication

CommandlineApplication::OLD_VERBOSE_VALUE

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Constants inherited from Base

Base::NAMESPACE

Class Method Summary collapse

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

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 = nil, run_already = true) ⇒ GenbankFlatFileFormatGenerator

#

initialize

#


34
35
36
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/genbank/genbank_flat_file_format_generator.rb', line 34

def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  case run_already # case tag
  when :do_not_run_yet
    run_already = false
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Hashes next
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :sequence_id
      # =================================================================== #
      if yielded.has_key? :sequence_id
        set_id(yielded.delete(:sequence_id))
      end
    # ===================================================================== #
    # === Handle Symbols next
    # ===================================================================== #
    elsif yielded.is_a? Symbol
      case yielded
      # =================================================================== #
      # === :be_quiet
      # =================================================================== #
      when :be_quiet
        @be_verbose = false
      end
    end
  end
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Bioroebe::GenbankFlatFileFormatGenerator[]

#


276
277
278
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 276

def self.[](i = ARGV)
  new(i)
end

Instance Method Details

#add(i) ⇒ Object

#

add

#


160
161
162
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 160

def add(i)
  @internal_hash[:string] << i
end

#add_required_contentObject

#

add_required_content

#


210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 210

def add_required_content
  add 'LOCUS       '+name_of_the_locus?+'                 '+n_nucleotides?.to_s+' bp            '+chromosome_form?+'       '+return_current_date+'
DEFINITION  No definition line found.
ACCESSION   '+name_of_the_locus?+'
VERSION     
KEYWORDS    .
SOURCE      Unknown.
ORGANISM  Unknown.
          Unclassified.
FEATURES             Location/Qualifiers
   source          1..'+n_nucleotides?.to_s+'
BASE COUNT       '+n_adenines?.to_s+' a     '+n_cytosines?.to_s+' c     '+n_guanines?.to_s+' g     '+n_thymines?.to_s+' t
ORIGIN
'+
return_chunked_numbered_and_properly_spaced_sequence+
'//
'
end

#chromosome_form?Boolean

#

chromosome_form?

This will be linear or circular chromosome.

#

Returns:

  • (Boolean)


179
180
181
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 179

def chromosome_form?
  'linear'
end

#input?Boolean Also known as: nucleotide_sequence?, dna_sequence?

#

input?

#

Returns:

  • (Boolean)


232
233
234
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 232

def input?
  @input
end

#n_adenines?Boolean

#

n_adenines?

#

Returns:

  • (Boolean)


132
133
134
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 132

def n_adenines?
  @input.count('a')
end

#n_cytosines?Boolean

#

n_cytosines?

#

Returns:

  • (Boolean)


139
140
141
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 139

def n_cytosines?
  @input.count('c')
end

#n_guanines?Boolean

#

n_guanines?

#

Returns:

  • (Boolean)


153
154
155
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 153

def n_guanines?
  @input.count('g')
end

#n_nucleotides?Boolean

#

n_nucleotides?

#

Returns:

  • (Boolean)


105
106
107
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 105

def n_nucleotides?
  @input.size
end

#n_thymines?Boolean

#

n_thymines?

#

Returns:

  • (Boolean)


146
147
148
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 146

def n_thymines?
  @input.count('t')
end

#name_of_the_locus?Boolean Also known as: sequence_id?, id?

#

name_of_the_locus?

#

Returns:

  • (Boolean)


240
241
242
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 240

def name_of_the_locus?
  @name_of_the_locus
end

#resetObject

#

reset (reset tag)

#


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 78

def reset
  super()
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  set_be_verbose
  # ======================================================================= #
  # === @shall_we_downcase
  # ======================================================================= #
  @shall_we_downcase = true
  # ======================================================================= #
  # === @internal_hash[:string]
  # ======================================================================= #
  @internal_hash[:string] = ''.dup # This is the one that will be output.
  set_name_of_the_locus
end

#return_chunked_numbered_and_properly_spaced_sequence(i = dna_sequence? ) ⇒ Object

#

return_chunked_numbered_and_properly_spaced_sequence

This method will display the nucleotides via a proper chunk.

#


259
260
261
262
263
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 259

def return_chunked_numbered_and_properly_spaced_sequence(
    i = dna_sequence?
  ) 
  ::Bioroebe.return_chunked_display(i)
end

#return_current_dateObject

#

return_current_date

#


167
168
169
170
171
172
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 167

def return_current_date
  day   = ::Time.now.strftime('%d')
  year  = ::Time.now.strftime('%Y')
  month = ::Time.now.strftime('%B').upcase # month tag
  "#{day}-#{month}-#{year}"
end

#return_nucleotide_sequence_as_ten_nucleotides_chunksObject

#

return_nucleotide_sequence_as_ten_nucleotides_chunks

This will return the input sequence in the form of chunks.

#


250
251
252
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 250

def return_nucleotide_sequence_as_ten_nucleotides_chunks
  ::Bioroebe.return_nucleotide_sequence_as_ten_nucleotides_chunks(nucleotide_sequence?)
end

#runObject

#

run (run tag)

#


268
269
270
271
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 268

def run
  add_required_content
  show_main_string
end

#set_input(i = '', shall_we_downcase = shall_we_downcase? ) ⇒ Object

#

set_input

#


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 112

def set_input(
    i                 = '',
    shall_we_downcase = shall_we_downcase?
  )
  i = i.first if i.is_a? Array
  i = i.to_s.dup.strip
  if i and File.file?(i)
    i = File.readlines(i)
    i.shift if i.first.start_with?('>')
    i = i.join("\n")
  end
  if shall_we_downcase
    i.downcase! # For now we keep everything downcased, as this is the default for GenBank files.
  end
  @input = i
end

#set_name_of_the_locus(i = DEFAULT_NAME_OF_THE_LOCUS) ⇒ Object Also known as: use_this_as_id=, set_id

#

set_name_of_the_locus

#


202
203
204
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 202

def set_name_of_the_locus(i = DEFAULT_NAME_OF_THE_LOCUS)
  @name_of_the_locus = i
end

#shall_we_downcase?Boolean

#

shall_we_downcase?

#

Returns:

  • (Boolean)


98
99
100
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 98

def shall_we_downcase?
  @shall_we_downcase
end

#show_main_string(be_verbose = be_verbose? ) ⇒ Object

#

show_main_string

#


186
187
188
189
190
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 186

def show_main_string(
    be_verbose = be_verbose?
  )
  e string? if be_verbose
end

#string?Boolean

#

string?

#

Returns:

  • (Boolean)


195
196
197
# File 'lib/bioroebe/genbank/genbank_flat_file_format_generator.rb', line 195

def string?
  @internal_hash[:string]
end