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


486
487
488
489
490
# File 'lib/bio/appl/blast/report.rb', line 486

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

Instance Method Details

#entryObject

current raw entry as a String


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

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

#entry_ended_posObject

(end position of the entry) + 1


545
546
547
548
549
550
# File 'lib/bio/appl/blast/report.rb', line 545

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


537
538
539
540
541
542
# File 'lib/bio/appl/blast/report.rb', line 537

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


506
507
508
509
510
511
512
513
514
515
516
# File 'lib/bio/appl/blast/report.rb', line 506

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


519
520
521
522
523
524
525
526
527
528
# File 'lib/bio/appl/blast/report.rb', line 519

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


493
494
495
496
497
498
# File 'lib/bio/appl/blast/report.rb', line 493

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

#skip_leaderObject

do nothing


501
502
503
# File 'lib/bio/appl/blast/report.rb', line 501

def skip_leader
  nil
end