class Bio::Blast::RPSBlast::Report::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 54 def initialize(klass, bstream) 55 super(klass, bstream) 56 @entry_head = nil 57 end
Public Instance Methods
get_entry()
click to toggle source
gets an entry
# File lib/bio/appl/blast/rpsblast.rb 73 def get_entry 74 p0 = stream_pos() 75 pieces = [] 76 flag_head = false # reached to start of header 77 flag_body = false # reached to start of body (Query=...) 78 while x = stream.gets(Delimiter) 79 if ReportHead =~ x then 80 case $1 81 when 'RPS-BLAST' 82 if pieces.empty? then 83 @entry_head = nil 84 flag_head = true 85 else 86 stream.ungets(x) 87 break 88 end 89 when 'Query=' 90 if flag_body then 91 stream.ungets(x) 92 break 93 else 94 @entry_head = pieces.join('') if flag_head 95 flag_body = true 96 end 97 else 98 raise 'Bug: should not reach here' 99 end 100 end #if ReportHead... 101 pieces.push x 102 end #while 103 p1 = stream_pos() 104 105 self.entry_start_pos = p0 106 self.entry = 107 if pieces.empty? then 108 nil 109 elsif !flag_head and @entry_head then 110 @entry_head + pieces.join('') 111 else 112 pieces.join('') 113 end 114 self.entry_ended_pos = p1 115 return self.entry 116 end
rewind()
click to toggle source
Rewinds the stream
Calls superclass method
Bio::FlatFile::Splitter::Template#rewind
# File lib/bio/appl/blast/rpsblast.rb 67 def rewind 68 @entry_head = nil 69 super 70 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 61 def skip_leader 62 stream.skip_spaces 63 return nil 64 end