Module: BioLocus::Store

Defined in:
lib/bio-locus/store.rb

Class Method Summary collapse

Class Method Details

.run(options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bio-locus/store.rb', line 6

def Store.run(options)
  store = Moneta.new(:LocalMemCache, file: options[:db])
  count = count_new = count_dup = 0
  STDIN.each_line do | line |
    Keys::each_key(line,options) do | key |
      if not store[key]
        count_new += 1 
        store[key] = true
      else
        count_dup += 1
        if options[:debug]
          $stderr.print "Store hit: <#{key}>\n"
        end
      end
      count += 1
      $stderr.print '.' if (count % 1_000_000) == 0 if not options[:quiet]
      next
    end
  end
  store.close
  $stderr.print "Stored #{count_new} positions out of #{count} in #{options[:db]} (#{count_dup} hits)\n" if !options[:quiet]
end