Class: Bioroebe::CreateAnnotationFormat

Inherits:
CommandlineApplication show all
Defined in:
lib/bioroebe/annotations/create_annotation_format.rb

Overview

Bioroebe::CreateAnnotationFormat

Constant Summary collapse

NAME_OF_THE_GENE =
#

NAME_OF_THE_GENE

#
'PAX6_Gene'

Constants inherited from CommandlineApplication

Bioroebe::CommandlineApplication::OLD_VERBOSE_VALUE

Constants included from ColoursForBase

Bioroebe::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) ⇒ CreateAnnotationFormat

#

initialize

The first argument should be an existing file.

#


33
34
35
36
37
38
39
40
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 33

def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input_file(i)
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Bioroebe::CreateAnnotationFormat[]

#


199
200
201
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 199

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

Instance Method Details

#add_name_of_the_gene_to_the_first_lineObject

#

add_name_of_the_gene_to_the_first_line

#


114
115
116
117
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 114

def add_name_of_the_gene_to_the_first_line
  _ = @name_of_the_gene
 @dataset[0] = @dataset[0]+T+_
end

#append_exon_stringObject

#

append_exon_string

#


143
144
145
146
147
148
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 143

def append_exon_string
  @dataset.map! {|line|
    line+T+'exon'
  }
  @dataset[0] = @dataset[0].sub(/exon/,'')
end

#append_newlineObject

#

append_newline

#


129
130
131
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 129

def append_newline
  @dataset << N
end

#input?Boolean Also known as: input_file?

#

input?

#

Returns:

  • (Boolean)


75
76
77
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 75

def input?
  @input_file
end

#purge_tabulator_tokensObject

#

purge_tabulator_tokens

#


153
154
155
156
157
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 153

def purge_tabulator_tokens
  @dataset.map! {|line|
    line.tr(T,' ')
  }
end

#read_in_dataset(from_this_file = input_file? ) ⇒ Object

#

read_in_dataset

#


82
83
84
85
86
87
88
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 82

def read_in_dataset(
    from_this_file = input_file?
  )
  if File.exist? from_this_file
    @dataset = File.readlines(from_this_file)
  end
end

#reject_intron_linesObject

#

reject_intron_lines

#


93
94
95
96
97
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 93

def reject_intron_lines
  @dataset.reject! {|line|
    line.include? 'intron'
  }
end

#remove_leading_cds_stringObject

#

remove_leading_cds_string

#


162
163
164
165
166
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 162

def remove_leading_cds_string
  @dataset.map! {|line|
    line.sub(/cds/, '')
  }
end

#replace_match_with_forward_strandObject

#

replace_match_with_forward_strand

#


122
123
124
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 122

def replace_match_with_forward_strand
  @dataset[0] = @dataset[0].sub(/match/,'>')
end

#report_datasetObject

#

report_dataset

#


136
137
138
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 136

def report_dataset
  e @dataset
end

#resetObject

#

reset (reset tag)

#


45
46
47
48
49
50
51
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 45

def reset
  super()
  # ======================================================================= #
  # === @name_of_the_gene
  # ======================================================================= #
  @name_of_the_gene = NAME_OF_THE_GENE
end

#runObject

#

run (run tag)

#


181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 181

def run
  try_to_infer_the_name_of_the_gene_from_the_name_of_the_input_file
  read_in_dataset
  reject_intron_lines
  select_entry_3_4_5
  add_name_of_the_gene_to_the_first_line
  replace_match_with_forward_strand
  append_exon_string
  remove_leading_cds_string
  purge_tabulator_tokens
  append_newline
  report_dataset
  save_into_a_file
end

#save_into_a_fileObject

#

save_into_a_file

#


171
172
173
174
175
176
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 171

def save_into_a_file
  what = @dataset.join(N)
  into = 'ANNOTATED_FILE_'+File.basename(input_file?)
  e 'Storing into `'+sfile(into)+'`.'
  write_what_into(what, into)
end

#select_entry_3_4_5Object

#

select_entry_3_4_5

We only select entry 3 4 and 5.

#


104
105
106
107
108
109
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 104

def select_entry_3_4_5
  @dataset.map! {|line|
    splitted = line.split(T)
    [ splitted[2], splitted[3], splitted[4] ].join(T)
  }
end

#set_input_file(i = '') ⇒ Object

#

set_input_file

#


66
67
68
69
70
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 66

def set_input_file(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @input_file = i
end

#try_to_infer_the_name_of_the_gene_from_the_name_of_the_input_fileObject

#

try_to_infer_the_name_of_the_gene_from_the_name_of_the_input_file

#


56
57
58
59
60
61
# File 'lib/bioroebe/annotations/create_annotation_format.rb', line 56

def try_to_infer_the_name_of_the_gene_from_the_name_of_the_input_file
  _ = File.basename(input_file?)
  _.gsub!(/#{File.extname(_)}/,'')
  _.gsub!(/Annotierung_1}/,'') # Some more sanitizing.
  @name_of_the_gene = _
end