Class: Fastq

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

Defined Under Namespace

Classes: Read

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Fastq

Returns a new instance of Fastq.



13
14
15
16
17
18
19
# File 'lib/fastq.rb', line 13

def initialize file
  if is_gzipped?(file)
    @io = IO.popen("zcat #{file}")
  else
    @io = File.open file
  end
end

Instance Method Details

#each_readObject



21
22
23
24
25
# File 'lib/fastq.rb', line 21

def each_read
  while read = get_read
    yield read
  end
end

#get_readObject



27
28
29
30
31
32
33
# File 'lib/fastq.rb', line 27

def get_read
  return nil unless id = @io.gets
  seq = @io.gets
  plus = @io.gets
  qual = @io.gets
  Fastq::Read.new *[ id, seq, qual ].map(&:chomp)
end