Module: ChromosomeRange

Extended by:
Entity
Defined in:
lib/rbbt/entity/chromosome_range.rb

Constant Summary

Constants included from Entity

Entity::UNPERSISTED_PREFIX

Class Method Summary collapse

Methods included from Entity

extended

Class Method Details

.text_to_unit(text) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rbbt/entity/chromosome_range.rb', line 16

def self.text_to_unit(text)
  text = text.sub('^', '+')
  base = text.to_f
  case
  when text =~ /KB?$/
    base * 1000
  when text =~ /MB?$/
    base * 1000_000
  when text =~ /^\d+(\.\d+)?(e\+\d+)?$/
    base
  else 
    raise "Text format not understood: #{ text }"
  end.to_i
end