module Indexer
Indexer
module for the FASTA class
This is a simple memory based key storage
Public Instance Methods
indexer_get(key)
click to toggle source
Get the key, return nil when not found
# File lib/bigbio/db/fasta/indexer.rb, line 23 def indexer_get key raise "Trying to use 'get' when there is no index" if @indexer == nil # raise "Indexer key #{key} not found!" if !@indexer[key] @indexer[key] end
indexer_get_by_index(idx)
click to toggle source
# File lib/bigbio/db/fasta/indexer.rb, line 29 def indexer_get_by_index idx @indexer.sort {|a,b| a[1]<=>b[1]} [idx] end
indexer_set(key, fpos)
click to toggle source
# File lib/bigbio/db/fasta/indexer.rb, line 15 def indexer_set key, fpos raise "Trying to use 'set' when there is no index" if @indexer == nil raise "Indexer key #{key} alread in use for <#{@indexer[key]}>!" if @indexer[key] # p [key, fpos] @indexer[key] = fpos end
indexer_use(state)
click to toggle source
Start using the indexer
# File lib/bigbio/db/fasta/indexer.rb, line 9 def indexer_use state if state @indexer = {} end end