Class: Bioroebe::Alignment
Overview
Constant Summary
CommandlineApplication::OLD_VERBOSE_VALUE
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Constants inherited
from Base
Base::NAMESPACE
Class Method Summary
collapse
-
.[](i = '') ⇒ Object
# === Bioroebe::Alignment[] ========================================================================= #.
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, #opne, #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, #set_be_verbose, #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
#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_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?, #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
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ Alignment
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/bioroebe/sequence/alignment.rb', line 34
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
case run_already
when :do_not_run,
:do_not_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
Bioroebe::Alignment[]
#
195
196
197
|
# File 'lib/bioroebe/sequence/alignment.rb', line 195
def self.[](i = '')
new(i)
end
|
Instance Method Details
#consensus_sequence? ⇒ Boolean
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/bioroebe/sequence/alignment.rb', line 144
def consensus_sequence?
_ = ''.dup
@array_G.size.times {|index|
hash = {}
hash['A'] = @array_A[index]
hash['T'] = @array_T[index]
hash['C'] = @array_C[index]
hash['G'] = @array_G[index]
max = hash.max_by {|key, value| value }
_ << max.first
}
return _
end
|
#print_consensus_sequence ⇒ Object
#
print_consensus_sequence
#
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/bioroebe/sequence/alignment.rb', line 123
def print_consensus_sequence
e
erev 'The consensus sequence, derived from the above matrix, is:'
e
print ' '
@array_G.size.times {|index|
hash = {}
hash['A'] = @array_A[index]
hash['T'] = @array_T[index]
hash['C'] = @array_C[index]
hash['G'] = @array_G[index]
_ = hash.max_by {|key, value| value }
print mediumslateblue(_[0])+rev }
e Colours.rev
e
end
|
#print_row_for(i = 'A', array = @array_A) ⇒ Object
161
162
163
164
165
166
167
168
|
# File 'lib/bioroebe/sequence/alignment.rb', line 161
def print_row_for(
i = 'A', array = @array_A
)
print "#{rev} #{i}: " array.each {|entry| print steelblue(entry.round(1).to_s.ljust(4))
}; e
end
|
#reset ⇒ Object
56
57
58
|
# File 'lib/bioroebe/sequence/alignment.rb', line 56
def reset
super()
end
|
#run ⇒ Object
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/bioroebe/sequence/alignment.rb', line 173
def run
first = first?
if first and File.exist?(first)
dataset = file_readlines(first).map(&:strip)
work_on_this_array(dataset)
elsif first.nil? or first.empty?
erev 'Using the __END__ dataset of '+sfile(__FILE__)+rev+'.'
e
work_on_this_array(
DATA.read.split("\n")
)
else
work_on_this_array(commandline_arguments?)
end
end
|
#
This method is assumed to split a String into an Array, before then passing this into work_on_this_array().
#
66
67
68
69
70
|
# File 'lib/bioroebe/sequence/alignment.rb', line 66
def use_this_as_input(i)
work_on_this_array(
i.split("\n")
)
end
|
#work_on_this_array(i) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/bioroebe/sequence/alignment.rb', line 75
def work_on_this_array(i)
@array_A = []
@array_T = []
@array_C = []
@array_G = []
if i.respond_to? :first
first = i.first
else
first = i
end
first.size.times {|index|
hash = Hash.new(0)
hash['A'] = 0
hash['T'] = 0
hash['C'] = 0
hash['G'] = 0
vertical_row = i.map {|entry| entry[index] }
vertical_row.each {|key| hash[key] += 1 }
hash.each_pair {|key, value|
total_count = vertical_row.size
case key
when 'A'
@array_A << (value.to_i) / total_count.to_f
when 'T'
@array_T << (value.to_i) / total_count.to_f
when 'C'
@array_C << (value.to_i) / total_count.to_f
when 'G'
@array_G << (value.to_i) / total_count.to_f
end
}
}
print_row_for('A', @array_A)
print_row_for('T', @array_T)
print_row_for('C', @array_C)
print_row_for('G', @array_G)
print_consensus_sequence
end
|