Class: OligoEnumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/oligo_enumerator.rb

Overview

Class OligoEnumerator provides a simple means of generating unique tag sequences for testing and development

Author:

  • Genome Research Ltd.

Instance Method Summary collapse

Constructor Details

#initialize(size, initial = 0) ⇒ OligoEnumerator

Generate an oligo enumerator

Parameters:

  • size (Integer)

    The number of tags to generate


15
16
17
18
# File 'lib/oligo_enumerator.rb', line 15

def initialize(size, initial = 0)
  @size = size
  @initial = initial
end

Instance Method Details

#eachObject


24
25
26
27
28
# File 'lib/oligo_enumerator.rb', line 24

def each
  @size.times do |i|
    yield tag(i + @initial)
  end
end

#lastObject


20
21
22
# File 'lib/oligo_enumerator.rb', line 20

def last
  tag(@size)
end

#tag(i) ⇒ Object


30
31
32
# File 'lib/oligo_enumerator.rb', line 30

def tag(i)
  i.to_s(4).tr('0', 'A').tr('1', 'T').tr('2', 'C').tr('3', 'G')
end