class Bio::FlatFileIndex::BDB_1::BDBMappingFile

Attributes

filename[R]
flag[RW]
permission[RW]

Public Class Methods

new(filename, flag = BDBdefault.flag_read, permission = BDBdefault.permission) click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
110 def initialize(filename, flag = BDBdefault.flag_read,
111                permission = BDBdefault.permission)
112   @filename = filename
113   @flag = flag
114   @permission = permission
115   #@bdb = BDB::Btree.open(@filename, nil, @flag, @permission)
116 end
open(*arg) click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
106 def self.open(*arg)
107   self.new(*arg)
108 end

Public Instance Methods

add(key, val) click to toggle source

methods for writing

    # File lib/bio/io/flatfile/bdb.rb
145 def add(key, val)
146   open
147   val = val.to_a.join("\t")
148   s = @bdb[key]
149   if s then
150     s << "\t"
151     s << val
152     val = s
153   end
154   @bdb[key] = val
155   #DEBUG.print "add: key=#{key.inspect}, val=#{val.inspect}\n"
156   val
157 end
add_exclusive(key, val) click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
159 def add_exclusive(key, val)
160   open
161   val = val.to_a.join("\t")
162   s = @bdb[key]
163   if s then
164     raise RuntimeError, "keys must be unique, but key #{key.inspect} already exists"
165   end
166   @bdb[key] = val
167   #DEBUG.print "add_exclusive: key=#{key.inspect}, val=#{val.inspect}\n"
168   val
169 end
add_nr(key, val) click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
183 def add_nr(key, val)
184   open
185   s = @bdb[key]
186   if s then
187     a = s.split("\t")
188   else
189     a = []
190   end
191   a.concat val.to_a
192   a.sort!
193   a.uniq!
194   str = a.join("\t")
195   @bdb[key] = str
196   #DEBUG.print "add_nr: key=#{key.inspect}, val=#{str.inspect}\n"
197   str
198 end
add_overwrite(key, val) click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
171 def add_overwrite(key, val)
172   open
173   val = val.to_a.join("\t")
174   s = @bdb[key]
175   if s then
176     DEBUG.print "Warining: overwrote unique id #{key.inspect}\n"
177   end
178   @bdb[key] = val
179   #DEBUG.print "add_overwrite: key=#{key.inspect}, val=#{val.inspect}\n"
180   val
181 end
close() click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
130 def close
131   if @bdb then
132     DEBUG.print "BDBMappingFile: close #{@filename}\n"
133     @bdb.close
134     @bdb = nil
135   end
136   nil
137 end
open() click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
120 def open
121   unless @bdb then
122     DEBUG.print "BDBMappingFile: open #{@filename}\n"
123     @bdb = BDB::Btree.open(@filename, nil, @flag, @permission)
124     true
125   else
126     nil
127   end
128 end
records() click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
139 def records
140   @bdb.size
141 end
Also aliased as: size
size()
Alias for: records