Class: Bioroebe::CalculateMeltingTemperature
- Inherits:
-
CommandlineApplication
- Object
- Base
- CommandlineApplication
- Bioroebe::CalculateMeltingTemperature
- Defined in:
- lib/bioroebe/calculate/calculate_melting_temperature.rb
Overview
Bioroebe::CalculateMeltingTemperature
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- DEFAULT_SEQUENCE =
#
DEFAULT_SEQUENCE
#
'CGACGTTGTAAAACGACGGCCAGT'
- GAS_CONSTANT_R =
#
GAS_CONSTANT_R
#
1.987
- DO_TRUNCATE_IF_INPUT_STRING_IS_TOO_LONG =
#
DO_TRUNCATE_IF_INPUT_STRING_IS_TOO_LONG
#
true
Constants inherited from CommandlineApplication
Bioroebe::CommandlineApplication::OLD_VERBOSE_VALUE
Constants included from ColoursForBase
Bioroebe::ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary collapse
-
.show_formulas ⇒ Object
# === CalculateMeltingTemperature.show_formulas.
-
.wallace_method(at, gc) ⇒ Object
# === CalculateMeltingTemperature.wallace_method.
Instance Method Summary collapse
-
#calculate_tm(ct = 0.5, na = 50, formamide_concentration = 0) ⇒ Object
# === calculate_tm.
-
#initialize(i = nil, run_already = true) ⇒ CalculateMeltingTemperature
constructor
# === initialize ========================================================================= #.
-
#length? ⇒ Boolean
# === length? ========================================================================= #.
-
#report_molecular_weight ⇒ Object
# === report_molecular_weight.
-
#report_result ⇒ Object
(also: #report)
# === report_result ========================================================================= #.
-
#report_total_length ⇒ Object
# === report_total_length ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#result? ⇒ Boolean
(also: #result)
# === result? ========================================================================== #.
-
#return_possibly_truncated_input ⇒ Object
# === return_possibly_truncated_input.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#sequence? ⇒ Boolean
(also: #input?)
# === sequence? ========================================================================= #.
-
#set_sequence(i = DEFAULT_SEQUENCE) ⇒ Object
# === set_sequence.
-
#show_help ⇒ Object
# === show_help (help tag).
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, #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
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_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(i = nil, run_already = true) ⇒ CalculateMeltingTemperature
#
initialize
#
57 58 59 60 61 62 63 64 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 57 def initialize( i = nil, run_already = true ) reset set_sequence(i) run if run_already end |
Class Method Details
.show_formulas ⇒ Object
#
CalculateMeltingTemperature.show_formulas
The Wallace Method:
http://www.sigmaaldrich.com/technical-documents/articles/biology/oligos-melting-temp.html#equations
http://openwetware.org/wiki/Primer_Tm_estimation_methods
This method will simply show the Wallace-Formula.
The shorthand notation is:
Tm = 2°C(A+T) + 4°C(G+C)
Note that this is also known as the “GCx4+ATx2” rule. It works for DNA oligomers not longer than 13 nucleotides. This rule also does not take into account the order of nucleotides in the sequence, so it really is not the ideal solution.
#
370 371 372 373 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 370 def self.show_formulas Colours.e ' Tm = 2°C(A+T) + 4°C(G+C) # <-- The Wallace-Formula, proposed in 1979' end |
.wallace_method(at, gc) ⇒ Object
#
CalculateMeltingTemperature.wallace_method
The argument “at” means the sum of a and t, and “gc” means the sum of g and c.
So for instance, the string TGCTCA has 3 AT, and 3 GC, so the method will yield to us:
18
#
387 388 389 390 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 387 def self.wallace_method(at, gc) result = 4 * (gc) + 2 * (at) result end |
Instance Method Details
#calculate_tm(ct = 0.5, na = 50, formamide_concentration = 0) ⇒ Object
#
calculate_tm
Calculate the melting temperature.
Note that there are several different ways how the melting temperature (Tm) of an oligo-nucleotide can be calculated.
All of these methods will yield slightly different results.
All of these calculations are also theoretical calculations based on certain assumptions.
The Optimum Tm values should still be determined empirically.
Now, let's explain the arguments to this method:
* ct: concentration of oligo nucleotide(mM) (default 0.5)
* na: concentration of Na⁺ (mM) (default 50)
* formamide_concentration: concentration of Formamide (mol/L) (default 0)
* This method will return a Float.
#
162 163 164 165 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 162 def calculate_tm( ct = 0.5, na = 50, formamide_concentration = 0 ) # ======================================================================= # # === How much formamide we threw into this # ======================================================================= # formamide_concentration = formamide_concentration.to_f # concentration of Formamide (mol/L) ct = ct / 1000000.0 # concentration of oligo (mol/L) na = na / 1000.0 # concentration of Na+ (mol/L) len = sequence?.length # .prec_f # base length # ======================================================================= # # === Thermodynamic parameters # # delta_enthalpy ... delta enthalpy # delta_entropy ... delta entropy # # ======================================================================= # # ======================================================================= # # === Delta Enthalpy # # Different combinations of nucleotides have a different enthalpy. # ======================================================================= # delta_enthalpy = { 'AA' => -9.1, 'TT' => -9.1, 'AT' => -8.6, 'TA' => -6.0, 'CA' => -5.8, 'TG' => -5.8, 'GT' => -6.5, 'AC' => -6.5, 'CT' => -7.8, 'AG' => -7.8, 'GA' => -5.6, 'TC' => -5.6, 'CG' => -11.9, 'GC' => -11.1, 'GG' => -11.0, 'CC' => -11.0 } # ======================================================================= # # === Delta entropy # ======================================================================= # delta_entropy = { 'AA' => -24.0, 'TT' => -24.0, 'AT' => -23.9, 'TA' => -16.9, 'CA' => -12.9, 'TG' => -12.9, 'GT' => -17.3, 'AC' => -17.3, 'CT' => -20.8, 'AG' => -20.8, 'GA' => -13.5, 'TC' => -13.5, 'CG' => -27.8, 'GC' => -26.7, 'GG' => -26.6, 'CC' => -26.6 } tot_h = 0.0 tot_s = 0.0 # ======================================================================= # # Count up the total enthalpy and entropy. # ======================================================================= # (sequence?.size - 2).times {|counter| enthalpy = @sequence.slice(counter, 2) tot_h += delta_enthalpy[enthalpy] entropy = @sequence.slice(counter, 2) tot_s += delta_entropy[entropy] } # ======================================================================= # # Obtain the amount of AT and GC. # ======================================================================= # at = ::Bioroebe.count_AT(@sequence) gc = ::Bioroebe.count_GC(@sequence) report_total_length # Notify the user of the current total length. # ======================================================================= # # === Show AT and GC counts next, including percentage. # ======================================================================= # erev 'AT count is: '+simp(at.to_s)+rev+' nucleotides ('+ sfancy(at * 100 / @sequence.size).to_s+rev+'%)' erev 'GC count is: '+simp(gc.to_s)+rev+' nucleotides ('+ sfancy(gc * 100 / @sequence.size).to_s+rev+'%)' # ======================================================================= # # We have to calculate the tm first. We do this by also considering # the gas constant. # ======================================================================= # tm = ( (1000 * tot_h) / (-10.8+tot_s+GAS_CONSTANT_R * Math.log(ct/4)) ) - 273.15 + 16.6 * Math.log10(na) # ======================================================================= # # === First the traditional GC% method. # ======================================================================= # if tm > 80 # ===================================================================== # # The traditional GC% method comes next. # ===================================================================== # tm = 81.5+16.6 * Math.log10(na) + 41 * ((gc)/len)-500/len-0.62 * formamide_concentration elsif tm < 20 # ===================================================================== # # === Wallace Method # # The Wallace method, also known as "2+4 rule of thumb". # # This very simple method assigns 2°C to each A-T pair and 4°C to # each G-C pair. The Tm then is the sum of these values for all # individual pairs in a DNA double strand. # # This takes into account that the G-C bond is stronger than the # A-T bond. Note that the 2+4 rule is valid only for a small # length-range, about 20-40 nt - rather 20, than towards 40, # though. # # The Wallace equation was developed for short DNA oligos of # 14-20 base pairs. # # See documentation at: # # https://www.sigmaaldrich.com/technical-documents/articles/biology/oligos-melting-temp.html#equations # # It is very easy to compute, but is of course also very inaccurate. # # Whenever possible, it should be avoided. # ===================================================================== # tm = CalculateMeltingTemperature.wallace_method(at, gc) else # tm = tm end @result = tm return tm end |
#length? ⇒ Boolean
#
length?
#
108 109 110 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 108 def length? @sequence.size end |
#report_molecular_weight ⇒ Object
#
report_molecular_weight
This method will report the molecular weight of the nucleotides at hand, in Dalton.
#
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 312 def report_molecular_weight molecular_weight = 0 hash = {} if File.exist? FILE_NUCLEOTIDES dataset = YAML.load_file(FILE_NUCLEOTIDES) end unless Object.const_defined? :ChemistryParadise begin require 'chemistry_paradise/utility_scripts/calculate_atomic_mass.rb' rescue LoadError; end end hash['A'] = ::ChemistryParadise.return_molmasse(dataset['Desoxyadenosin']) hash['T'] = ::ChemistryParadise.return_molmasse(dataset['Desoxythymidin']) hash['C'] = ::ChemistryParadise.return_molmasse(dataset['Desoxycytidin']) hash['G'] = ::ChemistryParadise.return_molmasse(dataset['Desoxyguanosin']) internal_PO2_group = 62.972 index = 0 sequence?.split(//).each {|this_nucleotide| add_this = hash[this_nucleotide].to_f case index when 0 else # Else add an internal PO2 group, its weight that is. add_this += internal_PO2_group end molecular_weight += add_this index += 1 } erev "Molecular weight: "\ "#{sfancy(molecular_weight.to_s)}"\ "#{rev}" end |
#report_result ⇒ Object Also known as: report
#
report_result
#
293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 293 def report_result round_to_n_numbers = 5 report_molecular_weight erev "The melting temperature of `#{simp(return_possibly_truncated_input)}"\ "#{rev}` is #{sfancy(@result.round(round_to_n_numbers).to_s)}#{rev} °C." if @sequence.to_s.empty? erev 'Notification: it seems as if you did not pass any nucleotide '\ 'string to this.' erev 'You could try to "assign" a string or generate a random one '\ 'via "assign random".' end end |
#report_total_length ⇒ Object
#
report_total_length
#
100 101 102 103 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 100 def report_total_length e "#{rev}The total length of this nucleotide-sequence "\ "is #{simp(length?.to_s)}." end |
#reset ⇒ Object
#
reset (reset tag)
#
69 70 71 72 73 74 75 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 69 def reset super() # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE end |
#result? ⇒ Boolean Also known as: result
#
result?
#
128 129 130 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 128 def result? @result end |
#return_possibly_truncated_input ⇒ Object
#
return_possibly_truncated_input
This method is needed to truncate too long input.
#
117 118 119 120 121 122 123 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 117 def return_possibly_truncated_input _ = @sequence.to_s if _.size > 60 # Bit more than 50 to account for the length of the message below. _ = _[0..49]+' [TRUNCATED PAST 50 CHARACTERS]' end if DO_TRUNCATE_IF_INPUT_STRING_IS_TOO_LONG return _ end |
#run ⇒ Object
#
run (run tag)
#
347 348 349 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 347 def run calculate_tm end |
#sequence? ⇒ Boolean Also known as: input?
#
sequence?
#
135 136 137 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 135 def sequence? @sequence end |
#set_sequence(i = DEFAULT_SEQUENCE) ⇒ Object
#
set_sequence
Set the main sequence, the input, to this method.
#
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 82 def set_sequence(i = DEFAULT_SEQUENCE) i = i.first if i.is_a? Array i = DEFAULT_SEQUENCE if i.nil? i = i.to_s case i.delete('-') # case tag # ======================================================================= # # === melting_temperature --help # ======================================================================= # when 'help' show_help; exit end i = i.upcase @sequence = i end |
#show_help ⇒ Object
#
show_help (help tag)
To show this help section, try:
cmt --help
#
284 285 286 287 288 |
# File 'lib/bioroebe/calculate/calculate_melting_temperature.rb', line 284 def show_help e opnn; e 'Simply input the DNA sequence.' e end |