Class: Bioroebe::CheckForMismatches
Overview
Constant Summary
collapse
- COLOUR_TO_BE_USED_FOR_A_MISMATCH =
#
COLOUR_TO_BE_USED_FOR_A_MISMATCH
This constant can be used to colourize a mismatch. Make sure that this is a Symbol, ideally.
#
:tomato
Bioroebe::CommandlineApplication::OLD_VERBOSE_VALUE
Bioroebe::ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Constants inherited
from Base
Base::NAMESPACE
Instance Method Summary
collapse
#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
#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
#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
#internal_hash?, #reset_the_internal_hash
#infer_the_namespace, #namespace?
Constructor Details
#initialize(input = ARGV, run_already = true) ⇒ CheckForMismatches
33
34
35
36
37
38
39
40
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 33
def initialize(
input = ARGV,
run_already = true
)
reset
set_commandline_input(input)
run if run_already
end
|
Instance Method Details
#array_mismatches? ⇒ Boolean
114
115
116
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 114
def array_mismatches?
@array_mismatches
end
|
#chop_down_to_sequence_length(i) ⇒ Object
#
chop_down_to_sequence_length
#
149
150
151
152
153
154
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 149
def chop_down_to_sequence_length(i)
if i.size > @first_sequence.size
i = i[0, @first_sequence.size]
end
return i
end
|
#corresponding_nucleotide(i) ⇒ Object
#
corresponding_nucleotide
#
121
122
123
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 121
def corresponding_nucleotide(i)
return_dna_match(i)
end
|
#
This method is to fetch user input.
#
90
91
92
93
94
95
96
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 90
def get_user_input
opnerev 'Input your first sequence now:'
first_sequence = $stdin.gets.chomp
opnerev 'Input your second sequence now:'
second_sequence = $stdin.gets.chomp
set_data(first_sequence, second_sequence)
end
|
139
140
141
142
143
144
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 139
def handle_given_commandline_input(i = @commandline_input)
unless i.empty?
set_data(i)
@obtain_user_input = false
end
end
|
#report_results ⇒ Object
Also known as:
report
#
report_results (report tag)
#
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 166
def report_results
mismatches = array_mismatches?
if mismatches.empty?
e
erev 'We found no mismatch.'
e
else
e
erev swarn('Mismatches')+rev+' were found at the following locations:'
e
first_sequence = @first_sequence
second_sequence = @second_sequence
colourized_first_sequence = first_sequence.dup
colourized_second_sequence = second_sequence.dup
mismatches.each {|index, character|
e rev+' Position: '+simp(index.to_s)+rev+
', Nucleotide being: '+sfancy(character.to_s)
}
e
array_mismatches?.reverse.each {|index, character|
colourized_first_sequence[index-1,1] = send(COLOUR_TO_BE_USED_FOR_A_MISMATCH, character)+
rev
corresponding_character = colourized_second_sequence[index-1,1]
colourized_second_sequence[index-1,1] = send(COLOUR_TO_BE_USED_FOR_A_MISMATCH, corresponding_character)+
rev
}
e "#{rev}The two strands were:"
e
e rev+
" "+
turquoise(
chop_down_to_sequence_length(
return_one_to_ten+return_one_to_ten
)
)
e rev+" 5'-"+colourized_first_sequence
show_three_prime_colourized_sequence(colourized_second_sequence)
e
end
end
|
#reset ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 45
def reset
super()
infer_the_namespace
@first_sequence = nil
@second_sequence = nil
@obtain_user_input = true
@array_mismatches = [] end
|
#return_one_to_ten ⇒ Object
159
160
161
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 159
def return_one_to_ten
'1234567890'
end
|
#run ⇒ Object
217
218
219
220
221
222
223
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 217
def run
get_user_input if @obtain_user_input
opnerev 'We will now compare these two sequences'
opnerev 'for any potential mismatch(es).'
scan_for_mismatches
report_results
end
|
#scan_for_mismatches ⇒ Object
101
102
103
104
105
106
107
108
109
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 101
def scan_for_mismatches
@first_sequence.scan(/./).each_with_index {|character, index|
result = corresponding_nucleotide(@second_sequence[index])
if character == result else array_mismatches? << [index+1, character]
end
}
end
|
128
129
130
131
132
133
134
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 128
def set_commandline_input(i)
if i.is_a? Array
i = i.join(' ').strip
end
@commandline_input = i.to_s.dup
handle_given_commandline_input
end
|
#set_data(a = 'AAAAATTTTTCAAATTAA', b = 'TTTTTAAAAAATTTAAAA') ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 69
def set_data( a = 'AAAAATTTTTCAAATTAA',
b = 'TTTTTAAAAAATTTAAAA'
)
if a.include? '|'
splitted = a.split('|').map(&:strip)
a = splitted.first
b = splitted.last
end
@first_sequence = a.upcase @second_sequence = b.upcase end
|
#show_three_prime_colourized_sequence(i) ⇒ Object
#
show_three_prime_colourized_sequence
#
210
211
212
|
# File 'lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb', line 210
def show_three_prime_colourized_sequence(i)
e rev+" 3'-"+i
end
|