Class: Bio::Fasta::Report::FastaFormat10Splitter

Inherits:
Bio::FlatFile::Splitter::Template show all
Defined in:
lib/bio/appl/fasta/format10.rb

Overview

Splitter for Bio::FlatFile

Instance Attribute Summary

Attributes inherited from Bio::FlatFile::Splitter::Template

#entry, #entry_ended_pos, #entry_pos_flag, #entry_start_pos, #parsed_entry

Instance Method Summary collapse

Methods inherited from Bio::FlatFile::Splitter::Template

#get_parsed_entry, #rewind

Constructor Details

#initialize(klass, bstream) ⇒ FastaFormat10Splitter

creates a new splitter object


23
24
25
26
27
# File 'lib/bio/appl/fasta/format10.rb', line 23

def initialize(klass, bstream)
  super(klass, bstream)
  @delimiter = '>>>'
  @real_delimiter = /^\s*\d+\>\>\>\z/
end

Instance Method Details

#get_entryObject

gets an entry


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bio/appl/fasta/format10.rb', line 35

def get_entry
  p0 = stream_pos()
  pieces = []
  overrun = nil
  first = true
  while e = stream.gets(@delimiter)
    pieces.push e
    if @real_delimiter =~ e then
      if first then
        first = nil
      else
        overrun = $&
        break
      end
    end
  end

  ent = (pieces.empty? ? nil : pieces.join(''))
  if ent and overrun then
    ent[-overrun.length, overrun.length] = ''
    stream.ungets(overrun)
  end

  p1 = stream_pos()
  self.entry_start_pos = p0
  self.entry = ent
  self.entry_ended_pos = p1
  return ent
end

#skip_leaderObject

do nothing and returns nil


30
31
32
# File 'lib/bio/appl/fasta/format10.rb', line 30

def skip_leader
  nil
end