Class: Bioroebe::CalculateMeltingTemperatureForMoreThanThirteenNucleotides

Inherits:
CommandlineApplication show all
Defined in:
lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb

Overview

Bioroebe::CalculateMeltingTemperatureForMoreThanThirteenNucleotides

Constant Summary collapse

BASE_VALUE =
#

BASE_VALUE

#
100.5

Constants inherited from CommandlineApplication

Bioroebe::CommandlineApplication::OLD_VERBOSE_VALUE

Constants included from ColoursForBase

Bioroebe::ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Constants inherited from Base

Base::NAMESPACE

Instance Method Summary collapse

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, #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

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_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

Methods included from InternalHashModule

#internal_hash?, #reset_the_internal_hash

Methods included from InferTheNamespaceModule

#infer_the_namespace, #namespace?

Constructor Details

#initialize(i = ARGV, run_already = true) ⇒ CalculateMeltingTemperatureForMoreThanThirteenNucleotides

#

initialize

#


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 50

def initialize(
    i           = ARGV,
    run_already = true
  )
  reset
  set_nucleotide_sequence(i)
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_not_report_anything
    # ===================================================================== #
    when :do_not_report_anything
      @do_report = false 
    end
  end
  run if run_already
end

Instance Method Details

#calculate_Tm_valueObject

#

calculate_Tm_value

#


173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 173

def calculate_Tm_value
  result = BASE_VALUE
  # ======================================================================= #
  # Next, we will calculate the middle part:
  #
  #   (1)  (41 * (yG+zC) / (wA+xT+yG+zC))
  # 
  # ======================================================================= #
  middle_value1 = (  41.0 * (n_G?+n_C?) / n_nucleotides_in_total? )
  # ======================================================================= #
  # And this is the second middle value:
  #
  #   (820/(wA+xT+yG+zC)) + 16.6 * log10([Na+])
  #
  # ======================================================================= #
  middle_value2 = ( 820.0 / n_nucleotides_in_total? )
  result += ( middle_value1 - middle_value2)
  # ======================================================================= #
  # And the last part is the log result of the concentration of sodium:
  # ======================================================================= #
  log_result = 16.6 * log10(concentration_of_sodium)
  result += log_result
  @tm_value = result.round(3)
end

#concentration_of_sodiumObject

#

concentration_of_sodium

This reflects [Na+], that is the concentration of sodium.

For now it is hardcoded towards 50.0. In the future this may have to be adjusted.

#


213
214
215
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 213

def concentration_of_sodium
  @sodium_concentration # This is mMol so 50m Mol is 0.050 Mol.
end

#count_frequencies_of_the_nucleotidesObject

#

count_frequencies_of_the_nucleotides

#


104
105
106
107
108
109
110
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 104

def count_frequencies_of_the_nucleotides
  _ = @nucleotide_sequence
  @n_A = _.count('A')
  @n_T = _.count('T')
  @n_G = _.count('G')
  @n_C = _.count('C') 
end

#log10(i) ⇒ Object

#

log10

#


231
232
233
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 231

def log10(i)
  Math.log10(i)
end

#n_A?Boolean

#

n_A?

#

Returns:

  • (Boolean)


138
139
140
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 138

def n_A?
  @n_A
end

#n_C?Boolean

#

n_C?

#

Returns:

  • (Boolean)


159
160
161
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 159

def n_C?
  @n_C
end

#n_G?Boolean

#

n_G?

#

Returns:

  • (Boolean)


152
153
154
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 152

def n_G?
  @n_G
end

#n_nucleotides_in_total?Boolean

#

n_nucleotides_in_total?

#

Returns:

  • (Boolean)


166
167
168
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 166

def n_nucleotides_in_total?
  input_sequence?.size
end

#n_T?Boolean

#

n_T?

#

Returns:

  • (Boolean)


145
146
147
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 145

def n_T?
  @n_T
end

#nucleotide_sequence?Boolean Also known as: input_sequence?

#

nucleotide_sequence?

#

Returns:

  • (Boolean)


115
116
117
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 115

def nucleotide_sequence?
  @nucleotide_sequence
end

#report_results_from_the_frequencies_and_the_size_of_the_sequence_at_handObject

#

report_results_from_the_frequencies_and_the_size_of_the_sequence_at_hand

#


122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 122

def report_results_from_the_frequencies_and_the_size_of_the_sequence_at_hand
  if @do_report
    erev "This nucleotide sequence contains "\
         "#{sfancy(@nucleotide_sequence.size.to_s)}"\
         "#{rev} nucleotides. (#{orange(input_sequence?)}#{rev})"
    erev "The nucleotide-frequencies are: "\
         "#{simp(n_A?.to_s+'xA')}#{rev}, "\
         "#{simp(n_T?.to_s+'xT')}#{rev}, "\
         "#{simp(n_G?.to_s+'xG')}#{rev}, "\
         "#{simp(n_C?.to_s+'xC')}#{rev}"
  end 
end

#report_the_tm_valueObject Also known as: report

#

report_the_tm_value (report tag)

#


238
239
240
241
242
243
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 238

def report_the_tm_value
  if @do_report
    erev 'The calculated Tm value (salt-adjusted Tm) '\
         'is: '+sfancy(@tm_value)+rev+'°C'
  end
end

#resetObject

#

reset

#


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 72

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @nucleotide_sequence
  # ======================================================================= #
  @nucleotide_sequence = nil
  # ======================================================================= #
  # === @do_report
  # ======================================================================= #
  @do_report = true
  # ======================================================================= #
  # Set the default sodium concentration next.
  # ======================================================================= #
  set_sodium_concentration(:default)
end

#runObject

#

run

#


248
249
250
251
252
253
254
255
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 248

def run
  count_frequencies_of_the_nucleotides
  e if @do_report
  report_results_from_the_frequencies_and_the_size_of_the_sequence_at_hand
  calculate_Tm_value
  report_the_tm_value
  e if @do_report
end

#set_nucleotide_sequence(i) ⇒ Object

#

set_nucleotide_sequence

#


92
93
94
95
96
97
98
99
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 92

def set_nucleotide_sequence(i)
  if i.is_a? Array
    i = i.join.strip
  end
  i = i.dup if i.frozen?
  i.delete!(' ')
  @nucleotide_sequence = i
end

#set_sodium_concentration(i = :default) ⇒ Object

#

set_sodium_concentration

#


220
221
222
223
224
225
226
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 220

def set_sodium_concentration(i = :default)
  case i
  when :default
    i = 0.050
  end
  @sodium_concentration = i
end

#tm_value?Boolean

#

tm_value?

#

Returns:

  • (Boolean)


201
202
203
# File 'lib/bioroebe/calculate/calculate_melting_temperature_for_more_than_thirteen_nucleotides.rb', line 201

def tm_value?
  @tm_value
end