Class: BioVcf::VcfStatistics

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-vcf/vcfstatistics.rb

Instance Method Summary collapse

Constructor Details

#initializeVcfStatistics

Returns a new instance of VcfStatistics.



5
6
7
8
# File 'lib/bio-vcf/vcfstatistics.rb', line 5

def initialize
  @count = 0
  @ref_alt_count = {}
end

Instance Method Details

#add(rec) ⇒ Object



10
11
12
13
14
15
# File 'lib/bio-vcf/vcfstatistics.rb', line 10

def add rec
  @count += 1
  s = rec.ref+">"+rec.alt[0]
  @ref_alt_count[s] ||= 0
  @ref_alt_count[s] += 1
end


17
18
19
20
21
22
23
24
# File 'lib/bio-vcf/vcfstatistics.rb', line 17

def print
  puts "## ==== Statistics =================================="
  @ref_alt_count.sort_by {|k,v| v}.reverse.each do |k,v|
    printf k+"\t%d\t%2.0d%%\n",v,(v.to_f/@count*100).round
  end
  puts "Total\t#{@count}"
  puts "## =================================================="
end