Class: Bioroebe::SanitizeNucleotideSequence

Inherits:
Base
  • Object
show all
Defined in:
lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb

Overview

Bioroebe::SanitizeNucleotideSequence

Constant Summary

Constants inherited from Base

Base::NAMESPACE

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #file_readlines, #infer_the_namespace, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #namespace?, #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 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_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?

Constructor Details

#initialize(i = nil, run_already = true) ⇒ SanitizeNucleotideSequence

#

initialize

#

34
35
36
37
38
39
40
41
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 34

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

Class Method Details

.[](i = "1 ATCCG\n30 TTA") ⇒ Object

#

Bioroebe::SanitizeNucleotideSequence[]

#

110
111
112
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 110

def self.[](i = "1 ATCCG\n30 TTA") # This will become a consecutive nucleotide String.
  new(i).result?
end

Instance Method Details

#input?Boolean Also known as: result?

#

input?

#

Returns:

  • (Boolean)

88
89
90
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 88

def input?
  @input
end

#report_resultObject Also known as: report

#

report_result

This will report the result, but it has to be invoked manually.

#

97
98
99
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 97

def report_result
  e result?
end

#resetObject

#

reset (reset tag)

#

46
47
48
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 46

def reset
  super()
end

#runObject

#

run (run tag)

#

104
105
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 104

def run
end

#sanitize_inputObject

#

sanitize_input

#

70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 70

def sanitize_input
  @input.delete!("\n")
  @input.delete!("\\\\n")
  # ======================================================================= #
  # Next remove all numbers.
  # ======================================================================= #
  chars = input?.chars
  chars.reject! {|entry| entry =~ /\d+/ } # Reject numbers.
  @input = chars.join(' ')
  @input.delete!(' ')
  if @input.include? '/'
    @input.delete!('/')
  end
end

#set_input(i = '') ⇒ Object

#

set_input

#

53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 53

def set_input(
    i = ''
  )
  if i.is_a? Array
    if i.first.start_with?('>') and i.first.include?(N) # Assume gi number, which we will chop off.
      i[0] = i[0][i[0].index(N) .. -1] # Get all from the start, to the first newline.
    end 
    i = i.join(' ').strip
  end
  i = i.to_s.dup
  @input = i
  sanitize_input
end