Class: Bio::Blast::Report::BlastXmlSplitter

Inherits:
FlatFile::Splitter::Default show all
Defined in:
lib/bio/appl/blast/report.rb

Overview

Flatfile splitter for NCBI BLAST XML format. It is internally used when reading BLAST XML. Normally, users do not need to use it directly.

Instance Attribute Summary

Attributes inherited from FlatFile::Splitter::Default

#delimiter, #delimiter_overrun, #header

Attributes inherited from FlatFile::Splitter::Template

#entry_pos_flag, #parsed_entry

Instance Method Summary collapse

Constructor Details

#initialize(klass, bstream) ⇒ BlastXmlSplitter

creates a new splitter object



518
519
520
521
522
# File 'lib/bio/appl/blast/report.rb', line 518

def initialize(klass, bstream)
  super(klass, bstream)
  @parsed_entries = []
  @raw_unsupported = false
end

Instance Method Details

#entryObject

current raw entry as a String



563
564
565
566
# File 'lib/bio/appl/blast/report.rb', line 563

def entry
  raise 'not supported for new BLAST XML format' if @raw_unsupported
  super
end

#entry_ended_posObject

(end position of the entry) + 1



577
578
579
580
581
582
# File 'lib/bio/appl/blast/report.rb', line 577

def entry_ended_pos
  if entry_pos_flag then
    raise 'not supported for new BLAST XML format' if @raw_unsupported
  end
  super
end

#entry_start_posObject

start position of the entry



569
570
571
572
573
574
# File 'lib/bio/appl/blast/report.rb', line 569

def entry_start_pos
  if entry_pos_flag then
    raise 'not supported for new BLAST XML format' if @raw_unsupported
  end
  super
end

#get_entryObject

get an entry and return the entry as a string



538
539
540
541
542
543
544
545
546
547
548
# File 'lib/bio/appl/blast/report.rb', line 538

def get_entry
  if @parsed_entries.empty? then
    @raw_unsupported = false
    ent = super
    prepare_parsed_entries(ent)
    self.parsed_entry = @parsed_entries.shift
  else
    raise 'not supported for new BLAST XML format'
  end
  ent
end

#get_parsed_entryObject

get an entry as a Bio::Blast::Report object



551
552
553
554
555
556
557
558
559
560
# File 'lib/bio/appl/blast/report.rb', line 551

def get_parsed_entry
  if @parsed_entries.empty? then
    get_entry
  else
    self.parsed_entry = @parsed_entries.shift
    self.entry = nil
    @raw_unsupported = true
  end
  self.parsed_entry
end

#rewindObject

rewinds



525
526
527
528
529
530
# File 'lib/bio/appl/blast/report.rb', line 525

def rewind
  ret = super
  @parsed_entries.clear
  @raw_unsupported = false
  ret
end

#skip_leaderObject

do nothing



533
534
535
# File 'lib/bio/appl/blast/report.rb', line 533

def skip_leader
  nil
end