Class Bio::Blast::RPSBlast::RPSBlastSplitter
In: lib/bio/appl/blast/rpsblast.rb
Parent: Bio::FlatFile::Splitter::Template

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.

Methods

get_entry   new   rewind   skip_leader  

Constants

ReportHead = /\A\n*(RPS\-BLAST|Query\=)/   Separator used to distinguish start of each report
Delimiter = "\n\n"   Delimiter used for IO#gets

Public Class methods

creates a new splitter object

[Source]

    # File lib/bio/appl/blast/rpsblast.rb, line 53
53:       def initialize(klass, bstream)
54:         super(klass, bstream)
55:         @entry_head = nil
56:       end

Public Instance methods

gets an entry

[Source]

     # File lib/bio/appl/blast/rpsblast.rb, line 72
 72:       def get_entry
 73:         p0 = stream_pos()
 74:         pieces = []
 75:         flag_head = false # reached to start of header
 76:         flag_body = false # reached to start of body (Query=...)
 77:         while x = stream.gets(Delimiter)
 78:           if ReportHead =~ x then
 79:             case $1
 80:             when 'RPS-BLAST'
 81:               if pieces.empty? then
 82:                 @entry_head = nil
 83:                 flag_head = true
 84:               else
 85:                 stream.ungets(x)
 86:                 break
 87:               end
 88:             when 'Query='
 89:               if flag_body then
 90:                 stream.ungets(x)
 91:                 break
 92:               else
 93:                 @entry_head = pieces.join('') if flag_head
 94:                 flag_body = true
 95:               end
 96:             else
 97:               raise 'Bug: should not reach here'
 98:             end
 99:           end #if ReportHead...
100:           pieces.push x
101:         end #while
102:         p1 = stream_pos()
103: 
104:         self.entry_start_pos = p0
105:         self.entry = 
106:           if pieces.empty? then
107:             nil
108:           elsif !flag_head and @entry_head then
109:             @entry_head + pieces.join('')
110:           else
111:             pieces.join('')
112:           end
113:         self.entry_ended_pos = p1
114:         return self.entry
115:       end

Rewinds the stream

[Source]

    # File lib/bio/appl/blast/rpsblast.rb, line 66
66:       def rewind
67:         @entry_head = nil
68:         super
69:       end

Skips leader of the entry. In this class, only skips space characters.

[Source]

    # File lib/bio/appl/blast/rpsblast.rb, line 60
60:       def skip_leader
61:         stream.skip_spaces
62:         return nil
63:       end

[Validate]