Class: Bioroebe::SanitizeNucleotideSequence
- Inherits:
-
Base
- Object
- Base
- Bioroebe::SanitizeNucleotideSequence
show all
- Defined in:
- lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb
Overview
Bioroebe::SanitizeNucleotideSequence
Constant Summary
Constants inherited
from Base
Base::NAMESPACE
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?, #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 BaseModule
#absolute_path, #default_file_read, #file_readlines
#internal_hash?, #reset_the_internal_hash
#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?
#infer_the_namespace, #namespace?
Constructor Details
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 34
def initialize(
i = nil,
run_already = true,
&block
)
reset
set_input(i)
if block_given?
yielded = yield
case yielded
when /do(_|-)?not(_|-)?remove(_|-)?newlines$/,
:do_not_remove_newlines
@shall_we_remove_newlines = false
end
end
run if run_already
end
|
Class Method Details
.[](i = "1 ATCCG\n30 TTA", &block) ⇒ Object
#
Bioroebe::SanitizeNucleotideSequence[]
This method will yield a consecutive nucleotide String by default.
#
148
149
150
151
152
153
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 148
def self.[](
i = "1 ATCCG\n30 TTA",
&block
)
new(i, &block).result?
end
|
Instance Method Details
123
124
125
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 123
def input?
@input
end
|
#report_result ⇒ Object
Also known as:
report
#
report_result
This will report the result, but it has to be invoked manually.
#
132
133
134
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 132
def report_result
e result?
end
|
#reset ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 61
def reset
super()
@shall_we_remove_newlines = true
end
|
#run ⇒ Object
139
140
141
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 139
def run
sanitize_the_input
end
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 98
def sanitize_the_input
@input.reject! {|entry| entry.empty? }
if shall_we_remove_newlines?
@input.map! {|entry|
entry = entry.delete("\n")
entry = entry.delete("\\\\n")
}
end
@input.map! {|entry|
chars = entry.chars
chars.reject! {|inner_entry| inner_entry =~ /\d+/ } if entry.include? '/'
entry.delete('/')
end
entry
}
@input = @input.join
end
|
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 81
def set_input(
i = ''
)
if i.is_a? Array
if i.first.start_with?('>') and i.first.include?(N) i[0] = i[0][i[0].index(N) .. -1] end
end
i = [i] unless i.is_a?(Array)
@input = i
end
|
#shall_we_remove_newlines? ⇒ Boolean
#
shall_we_remove_newlines?
#
74
75
76
|
# File 'lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb', line 74
def shall_we_remove_newlines?
@shall_we_remove_newlines
end
|