Class: Bio::DB::FastaLengthDB

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/util/bio-gngm.rb

Overview

Simple class representing a file of Fasta format sequences and each ones length

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ FastaLengthDB

Returns a new instance of FastaLengthDB.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bio/util/bio-gngm.rb', line 20

def initialize(args)
  @file = args[:file]
  @seqs = {}
  file = Bio::FastaFormat.open(@file)
  file.each do |entry|
    @seqs[entry.entry_id] = entry.length
  end
  
  def each
    @seqs.keys.sort.each do |k|
      yield k, @seqs[k]
    end
  end
  
end

Instance Method Details

#eachObject



28
29
30
31
32
# File 'lib/bio/util/bio-gngm.rb', line 28

def each
  @seqs.keys.sort.each do |k|
    yield k, @seqs[k]
  end
end