# File lib/bio/io/flatfile/bdb.rb, line 110 def initialize(filename, flag = BDBdefault.flag_read, permission = BDBdefault.permission) @filename = filename @flag = flag @permission = permission #@bdb = BDB::Btree.open(@filename, nil, @flag, @permission) end
methods for writing
# File lib/bio/io/flatfile/bdb.rb, line 145 def add(key, val) open val = val.to_a.join("\t") s = @bdb[key] if s then s << "\t" s << val val = s end @bdb[key] = val #DEBUG.print "add: key=#{key.inspect}, val=#{val.inspect}\n" val end
# File lib/bio/io/flatfile/bdb.rb, line 159 def add_exclusive(key, val) open val = val.to_a.join("\t") s = @bdb[key] if s then raise RuntimeError, "keys must be unique, but key #{key.inspect} already exists" end @bdb[key] = val #DEBUG.print "add_exclusive: key=#{key.inspect}, val=#{val.inspect}\n" val end
# File lib/bio/io/flatfile/bdb.rb, line 183 def add_nr(key, val) open s = @bdb[key] if s then a = s.split("\t") else a = [] end a.concat val.to_a a.sort! a.uniq! str = a.join("\t") @bdb[key] = str #DEBUG.print "add_nr: key=#{key.inspect}, val=#{str.inspect}\n" str end
# File lib/bio/io/flatfile/bdb.rb, line 171 def add_overwrite(key, val) open val = val.to_a.join("\t") s = @bdb[key] if s then DEBUG.print "Warining: overwrote unique id #{key.inspect}\n" end @bdb[key] = val #DEBUG.print "add_overwrite: key=#{key.inspect}, val=#{val.inspect}\n" val end
# File lib/bio/io/flatfile/bdb.rb, line 130 def close if @bdb then DEBUG.print "BDBMappingFile: close #{@filename}\n" @bdb.close @bdb = nil end nil end
# File lib/bio/io/flatfile/bdb.rb, line 120 def open unless @bdb then DEBUG.print "BDBMappingFile: open #{@filename}\n" @bdb = BDB::Btree.open(@filename, nil, @flag, @permission) true else nil end end
# File lib/bio/io/flatfile/bdb.rb, line 139 def records @bdb.size end
Generated with the Darkfish Rdoc Generator 2.