Sha256: d6aa7de6cade61b97356cf9429146097e6c91b44472fbeeb3f20074a2dccfb26
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
module BioLocus module Match def Match.run(options) do_delete = (options[:task] == :delete) invert_match = options[:invert_match] store = DbMapper.factory(options) lines = 0 header_lines = 0 count = 0 in_header = true uniq_match = {} uniq_no_match = {} STDIN.each_line do | line | if in_header and line =~ /^#/ # Retain comments in header (for VCF) print line header_lines += 1 next else in_header = false end if line =~ /^#/ header_lines += 1 else lines += 1 end $stderr.print '.' if (lines % 1_000_000) == 0 if not options[:quiet] Keys::each_key(line,options) do | key | has_match = lambda { if invert_match not store[key] else store[key] end } if has_match.call # We have a match $stderr.print "Matched <#{key}>\n" if options[:debug] count += 1 if do_delete store.delete(key) else print line uniq_match[key] ||= true end else uniq_no_match[key] ||= true end end end store.close if do_delete $stderr.print "\nDeleted #{count} keys in #{options[:db]} reading #{lines} lines !\n" if not options[:quiet] else $stderr.print "\nMatched #{count} (unique #{uniq_match.keys.size}) lines out of #{lines} (header #{header_lines}, unique #{uniq_no_match.keys.size+uniq_match.keys.size}) in #{options[:db]}!\n" if not options[:quiet] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bio-locus-0.0.7 | lib/bio-locus/match.rb |
bio-locus-0.0.6 | lib/bio-locus/match.rb |