class Bio::Blast::RPSBlast::FLATFILE_SPLITTER
Flatfile splitter for RPS-BLAST reports. It is internally used when reading RPS-BLAST report. Normally, users do not need to use it directly.
Note for Windows: RPS-BLAST results generated in Microsoft Windows may not be parsed correctly due to the line feed code problem. For a workaroud, convert line feed codes from Windows(DOS) to UNIX.
Constants
- Delimiter
Delimiter used for IO#gets
- ReportHead
Separator used to distinguish start of each report
Public Class Methods
new(klass, bstream)
click to toggle source
creates a new splitter object
Calls superclass method
Bio::FlatFile::Splitter::Template.new
# File lib/bio/appl/blast/rpsblast.rb, line 54 def initialize(klass, bstream) super(klass, bstream) @entry_head = nil end
Public Instance Methods
get_entry()
click to toggle source
gets an entry
# File lib/bio/appl/blast/rpsblast.rb, line 73 def get_entry p0 = stream_pos() pieces = [] flag_head = false # reached to start of header flag_body = false # reached to start of body (Query=...) while x = stream.gets(Delimiter) if ReportHead =~ x then case $1 when 'RPS-BLAST' if pieces.empty? then @entry_head = nil flag_head = true else stream.ungets(x) break end when 'Query=' if flag_body then stream.ungets(x) break else @entry_head = pieces.join('') if flag_head flag_body = true end else raise 'Bug: should not reach here' end end #if ReportHead... pieces.push x end #while p1 = stream_pos() self.entry_start_pos = p0 self.entry = if pieces.empty? then nil elsif !flag_head and @entry_head then @entry_head + pieces.join('') else pieces.join('') end self.entry_ended_pos = p1 return self.entry end
rewind()
click to toggle source
Rewinds the stream
Calls superclass method
Bio::FlatFile::Splitter::Template#rewind
# File lib/bio/appl/blast/rpsblast.rb, line 67 def rewind @entry_head = nil super end
skip_leader()
click to toggle source
Skips leader of the entry. In this class, only skips space characters.
# File lib/bio/appl/blast/rpsblast.rb, line 61 def skip_leader stream.skip_spaces return nil end