Class: Bioroebe::AminoacidsMassTable
- Defined in:
- lib/bioroebe/aminoacids/aminoacids_mass_table.rb
Overview
Bioroebe::AminoacidsMassTable
Constant Summary collapse
- PADDING_TO_USE =
#
PADDING_TO_USE
#
' '
Constants inherited from Base
Constants included from ColoursForBase
ColoursForBase::ARRAY_HTML_COLOURS_IN_USE
Class Method Summary collapse
-
.e(i = '') ⇒ Object
# === AminoacidsMassTable.e ========================================================================= #.
-
.erev(i) ⇒ Object
# === AminoacidsMassTable.erev ========================================================================= #.
-
.report_which_file_is_used ⇒ Object
# === AminoacidsMassTable.report_which_file_is_used.
-
.show(optional_padding = PADDING_TO_USE) ⇒ Object
# === Bioroebe::AminoacidsMassTable.show ========================================================================= #.
Instance Method Summary collapse
-
#initialize ⇒ AminoacidsMassTable
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
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 BaseModule
#absolute_path, #default_file_read, #file_readlines
Methods included from InternalHashModule
#internal_hash?, #reset_the_internal_hash
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 included from InferTheNamespaceModule
#infer_the_namespace, #namespace?
Constructor Details
#initialize ⇒ AminoacidsMassTable
#
initialize
#
25 26 27 28 |
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 25 def initialize reset Bioroebe::AminoacidsMassTable.show end |
Class Method Details
.e(i = '') ⇒ Object
#
AminoacidsMassTable.e
#
47 48 49 |
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 47 def self.e(i = '') puts i end |
.erev(i) ⇒ Object
#
AminoacidsMassTable.erev
#
40 41 42 |
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 40 def self.erev(i) ::Bioroebe.erev(i) end |
.report_which_file_is_used ⇒ Object
#
AminoacidsMassTable.report_which_file_is_used
The purpose of this method is to simply report which file we use to read in the mass table.
#
101 102 103 104 105 |
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 101 def self.report_which_file_is_used erev 'We will read from the file `'+ Colours.sfile(FILE_AMINO_ACIDS_MASS_TABLE)+ Colours.rev+'`.' end |
.show(optional_padding = PADDING_TO_USE) ⇒ Object
#
Bioroebe::AminoacidsMassTable.show
#
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 54 def self.show( optional_padding = PADDING_TO_USE ) sum = 0 erev 'Aminoacids Mass Table - Molecular Weight of '\ 'Amino Acids:'; e # Need a newline here. AMINO_ACIDS_MASS_TABLE.each {|key, value| long_amino_acid = AMINO_ACIDS[key].select {|inner_key, _| inner_key.size == 3 }.values.first left = optional_padding+ key.to_s+ ' ('+long_amino_acid+')'+': ' sum += value # Add to the sum. # ===================================================================== # # Next pad the value. # ===================================================================== # value = value.to_s.rjust(10) value = '%.3f' % value value = value.rjust(10) left = left.ljust(23) # ===================================================================== # # The variable left may look like this: # " T (threonine): " # ===================================================================== # if left.include? '(' splitted = left.split('(') splitted[0] = ::Bioroebe.springgreen(splitted[0])+::Bioroebe.rev left = splitted.join('(') end erev left+ Colours.sfancy(value) } e erev 'Average weight of an amino acid: '+ Colours.simp( (sum.to_f / AMINO_ACIDS_MASS_TABLE.keys.size).round(2).to_s ) e # Trailing newline. end |
Instance Method Details
#reset ⇒ Object
#
reset
#
33 34 35 |
# File 'lib/bioroebe/aminoacids/aminoacids_mass_table.rb', line 33 def reset super() end |