class Bio::GFF::FastaReader
Read FASTA records from file and store seek positions, which are used to retrieve the records. Note, this implementation merely retains records in memory (FIXME)
Public Class Methods
new(fh, io_seek=nil)
click to toggle source
# File lib/bio/db/gff/file/gfffasta.rb, line 18 def initialize fh, io_seek=nil @fh = fh @h = {} parse end
Public Instance Methods
[](index)
click to toggle source
# File lib/bio/db/gff/file/gfffasta.rb, line 42 def [] index @h[index] end
each() { |k, v| ... }
click to toggle source
# File lib/bio/db/gff/file/gfffasta.rb, line 46 def each @h.each do | k,v | yield k, v end end
parse()
click to toggle source
# File lib/bio/db/gff/file/gfffasta.rb, line 24 def parse # read FASTA records header = nil seqs = [] @fh.each_line do | line | line = line.strip next if line =~ /^#/ if line =~ /^>/ # FASTA record header add(header,seqs) header = line seqs = [] else seqs << line.gsub(/\s+/,'') end end add(header,seqs) end
Private Instance Methods
add(header, seqs)
click to toggle source
# File lib/bio/db/gff/file/gfffasta.rb, line 53 def add header, seqs if header id, fastarec = fasta_rec(header, seqs) @h[id] = fastarec.data.strip end end
fasta_rec(header, buf)
click to toggle source
# File lib/bio/db/gff/file/gfffasta.rb, line 60 def fasta_rec header, buf fst = Bio::FastaFormat.new(header+"\n"+buf.join('')) return fst.definition, fst end