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

new(klass, bstream)

creates a new splitter object

[Source]

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

### Public Instance methods

get_entry()

gets an entry

[Source]

         # File lib/bio/appl/blast/rpsblast.rb, line 73
     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()

Rewinds the stream

[Source]

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

skip_leader()

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

[Source]

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

[Validate]