Class: FastaParser
- Inherits:
-
Object
- Object
- FastaParser
- Defined in:
- lib/parsers/fasta.rb
Instance Method Summary collapse
- #each {|Fasta.new(:name => header, :sequence => sequence)| ... } ⇒ Object
-
#initialize(handle) ⇒ FastaParser
constructor
A new instance of FastaParser.
Constructor Details
#initialize(handle) ⇒ FastaParser
Returns a new instance of FastaParser.
3 4 5 |
# File 'lib/parsers/fasta.rb', line 3 def initialize(handle) @handle = handle end |
Instance Method Details
#each {|Fasta.new(:name => header, :sequence => sequence)| ... } ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/parsers/fasta.rb', line 7 def each sequence, header = nil, nil @handle.each do |line| if line[0].chr == '>' yield Fasta.new(:name => header, :sequence => sequence) if sequence sequence = '' header = line[1..-1].strip else sequence << line.strip.tr(' ','') end end yield Fasta.new(:name => header, :sequence => sequence) end |