Class: Bioroebe::CalculateBlosumScore
- Defined in:
- lib/bioroebe/calculate/calculate_blosum_score.rb
Overview
Bioroebe::CalculateBlosumScore
Constant Summary collapse
- GAP_OPEN_COST =
#
GAP_OPEN_COST
Two constants to define initially the cost for gap-open and gap-extension costs.
#
-12
- GAP_EXTENSION_COST =
#
GAP_EXTENSION_COST
#
-2
Constants inherited from Base
Constants included from ColoursForBase
Bioroebe::ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Instance Method Summary collapse
-
#initialize(parse_this_input = nil) ⇒ CalculateBlosumScore
constructor
# === initialize.
-
#parse_input(i, be_verbose = :be_quiet) ⇒ Object
(also: #test)
# === parse_input.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#score? ⇒ Boolean
(also: #result?)
# === score? ========================================================================= #.
-
#set_score(i) ⇒ Object
# === set_score ========================================================================= #.
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
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?
Constructor Details
#initialize(parse_this_input = nil) ⇒ CalculateBlosumScore
#
initialize
The input to initialite should be a String.
#
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bioroebe/calculate/calculate_blosum_score.rb', line 41 def initialize( parse_this_input = nil ) reset # ======================================================================= # # Determine which blosum-dataset to use next: # ======================================================================= # blosum50_dataset = Bioroebe::BlosumParser.new(FILE_BLOSUM50) @hash = blosum50_dataset.hash if parse_this_input # If we provided an Argument, we will assume this to be a String, and parse it. parse_input(parse_this_input) end end |
Instance Method Details
#parse_input(i, be_verbose = :be_quiet) ⇒ Object Also known as: test
#
parse_input
We parse the given input here. This should be in the form of an Aminoacid-chain, but we will also handle input that is
#
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 |
# File 'lib/bioroebe/calculate/calculate_blosum_score.rb', line 76 def parse_input( i, be_verbose = :be_quiet ) if be_verbose == :be_verbose erev "Working on the input String: \n"+steelblue(i)+rev end i = i.strip array_that_holds_our_two_aminoacids = i.split(N).map(&:strip).reject(&:empty?) first_array = array_that_holds_our_two_aminoacids.first.chars second_array = array_that_holds_our_two_aminoacids[1].chars this_is_the_input = first_array.zip(second_array).map {|entry| entry.join } score = 0 # We assume the initial score to be 0. @found_a_gap = false this_is_the_input.each {|entry| if @hash.has_key? entry @found_a_gap = false score += @hash[entry].to_i else # This here handles gaps. # We must distinguish between a gap-open cost and a gap extension # cost. if @found_a_gap # If this is already true, then it must be a gap-extension. score += @gap_extension_cost else # Else it must be a gap-open cost. score += @gap_open_cost end @found_a_gap = true end } set_score(score) # Store the result for the score as well. e score end |
#reset ⇒ Object
#
reset
#
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bioroebe/calculate/calculate_blosum_score.rb', line 58 def reset super() # ======================================================================= # # === @gap_open_cost # ======================================================================= # @gap_open_cost = GAP_OPEN_COST # ======================================================================= # # === @gap_extension_cost # ======================================================================= # @gap_extension_cost = GAP_EXTENSION_COST end |
#score? ⇒ Boolean Also known as: result?
#
score?
#
118 119 120 |
# File 'lib/bioroebe/calculate/calculate_blosum_score.rb', line 118 def score? @score end |
#set_score(i) ⇒ Object
#
set_score
#
111 112 113 |
# File 'lib/bioroebe/calculate/calculate_blosum_score.rb', line 111 def set_score(i) @score = i # Keep track of the score here. end |