Class: FastqParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dna/parsers/fastq.rb

Instance Method Summary collapse

Constructor Details

#initialize(handle) ⇒ FastqParser

Returns a new instance of FastqParser.



3
4
5
# File 'lib/dna/parsers/fastq.rb', line 3

def initialize(handle)
  @handle = handle
end

Instance Method Details

#eachObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dna/parsers/fastq.rb', line 7

def each
  c = (0..3).cycle
  params = { :name => nil, :sequence => nil, :quality => nil }
  @handle.each do |line|
    n = c.next
    case n
    when 0
      params[:name] = line.strip[1..-1]
    when 1
      params[:sequence] = line.strip
    when 2
      nil
    when 3
      params[:quality] = line.strip
      record = Fastq.new params
      yield record
    end
  end
end