Class: CdHitParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-cd-hit-report/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#report_fileObject

Returns the value of attribute report_file.



2
3
4
# File 'lib/bio-cd-hit-report/parser.rb', line 2

def report_file
  @report_file
end

Instance Method Details

#each {|Cluster.new(:name => header, :data => data)| ... } ⇒ Object

Yields:

  • (Cluster.new(:name => header, :data => data))


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bio-cd-hit-report/parser.rb', line 4

def each
  data,header = nil, nil
  File.open(report_file).each do |line|
    if line[0].chr == '>'
      yield Cluster.new(:name => header,:data => data) if data
      data = ''
      header = line[1..-1].strip
    else
      data << line
    end
  end
  yield Cluster.new(:name => header, :data => data)
end