Class: Bio::DB::FastaLengthDB
- Inherits:
-
Object
- Object
- Bio::DB::FastaLengthDB
- Defined in:
- lib/bio_tools.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
-
#initialize(fasta) ⇒ FastaLengthDB
constructor
A new instance of FastaLengthDB.
Constructor Details
#initialize(fasta) ⇒ FastaLengthDB
Returns a new instance of FastaLengthDB.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bio_tools.rb', line 5 def initialize(fasta) @file = fasta @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 def [] (key) @seqs[key] end end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 |
# File 'lib/bio_tools.rb', line 19 def [] (key) @seqs[key] end |
#each ⇒ Object
13 14 15 16 17 |
# File 'lib/bio_tools.rb', line 13 def each @seqs.keys.sort.each do |k| yield k, @seqs[k] end end |