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



482
483
484
485
486
# File 'lib/bio/appl/blast/report.rb', line 482

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

Instance Method Details

#entryObject

current raw entry as a String



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

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

#entry_ended_posObject

(end position of the entry) + 1



541
542
543
544
545
546
# File 'lib/bio/appl/blast/report.rb', line 541

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



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

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



502
503
504
505
506
507
508
509
510
511
512
# File 'lib/bio/appl/blast/report.rb', line 502

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



515
516
517
518
519
520
521
522
523
524
# File 'lib/bio/appl/blast/report.rb', line 515

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

#rewindObject

rewinds



489
490
491
492
493
494
# File 'lib/bio/appl/blast/report.rb', line 489

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

#skip_leaderObject

do nothing



497
498
499
# File 'lib/bio/appl/blast/report.rb', line 497

def skip_leader
  nil
end