Class: Bio::Blast::RPSBlast::RPSBlastSplitter
- Inherits:
-
FlatFile::Splitter::Template
- Object
- FlatFile::Splitter::Template
- Bio::Blast::RPSBlast::RPSBlastSplitter
- Defined in:
- lib/bio/appl/blast/rpsblast.rb
Overview
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.
Constant Summary collapse
- ReportHead =
Separator used to distinguish start of each report
/\A\n*(RPS\-BLAST|Query\=)/
- Delimiter =
Delimiter used for IO#gets
"\n\n"
Instance Attribute Summary
Attributes inherited from FlatFile::Splitter::Template
#entry, #entry_ended_pos, #entry_pos_flag, #entry_start_pos, #parsed_entry
Instance Method Summary collapse
-
#get_entry ⇒ Object
gets an entry.
-
#initialize(klass, bstream) ⇒ RPSBlastSplitter
constructor
creates a new splitter object.
-
#rewind ⇒ Object
Rewinds the stream.
-
#skip_leader ⇒ Object
Skips leader of the entry.
Methods inherited from FlatFile::Splitter::Template
Constructor Details
#initialize(klass, bstream) ⇒ RPSBlastSplitter
creates a new splitter object
54 55 56 57 |
# File 'lib/bio/appl/blast/rpsblast.rb', line 54 def initialize(klass, bstream) super(klass, bstream) @entry_head = nil end |
Instance Method Details
#get_entry ⇒ Object
gets an entry
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# 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 ⇒ Object
Rewinds the stream
67 68 69 70 |
# File 'lib/bio/appl/blast/rpsblast.rb', line 67 def rewind @entry_head = nil super end |
#skip_leader ⇒ Object
Skips leader of the entry. In this class, only skips space characters.
61 62 63 64 |
# File 'lib/bio/appl/blast/rpsblast.rb', line 61 def skip_leader stream.skip_spaces return nil end |