Module: Bioroebe::RestrictionEnzymes::Statistics

Defined in:
lib/bioroebe/enzymes/restriction_enzymes/statistics.rb

Overview

Bioroebe::RestrictionEnzymes::Statistics

Class Method Summary collapse

Class Method Details

.erev(i = '') ⇒ Object

#

Bioroebe::RestrictionEnzymes::Statistics.erev

#


24
25
26
# File 'lib/bioroebe/enzymes/restriction_enzymes/statistics.rb', line 24

def self.erev(i = '')
  ::Bioroebe.erev(i)
end

.showObject

#

Bioroebe::RestrictionEnzymes::Statistics.show

#


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bioroebe/enzymes/restriction_enzymes/statistics.rb', line 31

def self.show
  require 'yaml'
  require 'bioroebe/colours/colours.rb'
  dataset = YAML.load_file(Bioroebe.file_restriction_enzymes)
  erev 'A total of '+dataset.keys.size.to_s+' restriction enzymes '\
       'are registered in this project.'
  array = []
  dataset.each_pair {|key, value|
    if value.include? ' '
      value = value.split(' ').first.to_s
    end
    array << value.size
  }
  hash = Hash.new
  hash.default = 0
  array.each {|entry|
    hash[entry] += 1
  }
  sorted = hash.sort_by {|key, value| key }
  e
  erev 'The composition is:'
  e
  sorted.each {|key, value|
    erev '  Restriction size '+key.to_s.rjust(2)+' is encountered '+
         ::Colours.lightblue(value.to_s.rjust(3))+
         +::Bioroebe.rev+' times.'
  }
  e
end