Class | Bio::FlatFileIndex::Indexer::Parser::TemplateParser
In: | lib/bio/io/flatfile/indexer.rb
Parent: | Object

### Methods

add_secondary_namespaces close_flatfile each new open_flatfile parse_primary parse_secondary set_primary_namespace

### Constants

NAMESTYLE | = | NameSpaces.new

### Attributes

dbclass | [W] |
dbclass | [R] |
errorlog | [R] |
fileid | [R] |
format | [R] |
format | [W] |
primary | [R] |
secondary | [R] |

### Public Class methods

new()

[Source]

        # File lib/bio/io/flatfile/indexer.rb, line 79
    79:           def initialize
    80:             @namestyle = self.class::NAMESTYLE
    81:             @secondary = NameSpaces.new
    82:             @errorlog = []
    83:           end

### Public Instance methods

add_secondary_namespaces(*names)

[Source]

         # File lib/bio/io/flatfile/indexer.rb, line 98
     98:           def add_secondary_namespaces(*names)
     99:             DEBUG.print "add_secondary_namespaces: #{names.inspect}\n"
    100:             names.each do |x|
    101:               unless x.is_a?(NameSpace) then
    102:                 y = @namestyle[x]
    103:                 raise 'unknown secondary namespace' unless y
    104:                 @secondary << y
    105:               end
    106:             end
    107:             true
    108:           end

close_flatfile()

[Source]

         # File lib/bio/io/flatfile/indexer.rb, line 164
    164:           def close_flatfile
    165:             DEBUG.print "close flatfile #{@flatfilename.inspect}\n"
    166:             @flatfile.close
    167:           end

each() {|pos, len| ...}

[Source]

         # File lib/bio/io/flatfile/indexer.rb, line 122
    122:           def each
    123:             @flatfile.each do |x|
    124:               @entry = x
    125:               pos = @flatfile.entry_start_pos
    126:               len = @flatfile.entry_ended_pos - @flatfile.entry_start_pos
    127:               begin
    128:                 yield pos, len
    129:               rescue RuntimeError, NameError => evar
    130:                 DEBUG.print "Caught error: #{evar.inspect}\n"
    131:                 DEBUG.print "in #{@flatfilename.inspect} position #{pos}\n"
    132:                 DEBUG.print "===begin===\n"
    133:                 DEBUG.print @flatfile.entry_raw.to_s.chomp
    134:                 DEBUG.print "\n===end===\n"
    135:                 @errorlog << [ evar, @flatfilename, pos ]
    136:                 if @fatal then
    137:                   DEBUG.print "Fatal error occurred, stop creating index...\n"
    138:                   raise evar
    139:                 else
    140:                   DEBUG.print "This entry shall be incorrectly indexed.\n"
    141:                 end
    142:               end #rescue
    143:             end
    144:           end

open_flatfile(fileid, file)

administration of a single flatfile

[Source]

         # File lib/bio/io/flatfile/indexer.rb, line 111
    111:           def open_flatfile(fileid, file)
    112:             @fileid = fileid
    113:             @flatfilename = file
    114:             DEBUG.print "fileid=#{fileid} file=#{@flatfilename.inspect}\n"
    115:             @flatfile = Bio::FlatFile.open(@dbclass, file, 'rb')
    116:             @flatfile.raw = nil
    117:             @flatfile.entry_pos_flag = true
    118:             @entry = nil
    119:           end

parse_primary()

[Source]

         # File lib/bio/io/flatfile/indexer.rb, line 146
    146:           def parse_primary
    147:             r = self.primary.proc.call(@entry)
    148:             unless r.is_a?(String) and r.length > 0
    149:               #@fatal = true
    150:               raise 'primary id must be a non-void string (skipped this entry)'
    151:             end
    152:             r
    153:           end

parse_secondary() {|x.name, y if y.length > 0| ...}

[Source]

         # File lib/bio/io/flatfile/indexer.rb, line 155
    155:           def parse_secondary
    156:             self.secondary.each do |x|
    157:               p = x.proc.call(@entry)
    158:               p.each do |y|
    159:                 yield x.name, y if y.length > 0
    160:               end
    161:             end
    162:           end

set_primary_namespace(name)

[Source]

        # File lib/bio/io/flatfile/indexer.rb, line 87
    87:           def set_primary_namespace(name)
    88:             DEBUG.print "set_primary_namespace: #{name.inspect}\n"
    89:             if name.is_a?(NameSpace) then
    90:               @primary = name
    91:             else
    92:               @primary = @namestyle[name]
    93:             end
    94:             raise 'unknown primary namespace' unless @primary
    95:             @primary
    96:           end

[Validate]