class Bio::FlatFileIndex::Indexer::Parser::TemplateParser

Constants

NAMESTYLE

Attributes

dbclass[RW]
errorlog[R]
fileid[R]
format[RW]
primary[R]
secondary[R]

Public Class Methods

new() click to toggle source
   # File lib/bio/io/flatfile/indexer.rb
79 def initialize
80   @namestyle = self.class::NAMESTYLE
81   @secondary = NameSpaces.new
82   @errorlog = []
83 end

Public Instance Methods

add_secondary_namespaces(*names) click to toggle source
    # File lib/bio/io/flatfile/indexer.rb
 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() click to toggle source
    # File lib/bio/io/flatfile/indexer.rb
164 def close_flatfile
165   DEBUG.print "close flatfile #{@flatfilename.inspect}\n"
166   @flatfile.close
167 end
each() { |pos, len| ... } click to toggle source
    # File lib/bio/io/flatfile/indexer.rb
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) click to toggle source

administration of a single flatfile

    # File lib/bio/io/flatfile/indexer.rb
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() click to toggle source
    # File lib/bio/io/flatfile/indexer.rb
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() { |name, y| ... } click to toggle source
    # File lib/bio/io/flatfile/indexer.rb
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) click to toggle source
   # File lib/bio/io/flatfile/indexer.rb
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