class BioVcf::VcfNucleotideCount4
Helper class for a list of (variant) values, such as A,G. The [] function does the hard work. You can pass in an index (integer) or nucleotide which translates to an index. (see ./features for examples)
Public Class Methods
new(alt,list)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 19 def initialize alt,list @alt = alt @list = list.split(/,/).map{|i| i.to_i} end
Public Instance Methods
[](idx)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 24 def [] idx if idx.kind_of?(Integer) # return a value @list[idx] elsif idx.kind_of?(String) # return a value @list[["A","C","G","T"].index(idx)] else idx.kind_of?(Array) # return a list of values idx.map { |nuc| idx2 = ["A","C","G","T"].index(nuc) # p [idx,nuc,idx2,@list] @list[idx2] } end end
max(list = @alt)
click to toggle source
Return the max value on the nucleotides in the list (typically rec.alt)
# File lib/bio-vcf/vcfgenotypefield.rb, line 46 def max list = @alt values = self[list] values.reduce(0){ |memo,v| (v>memo ? v : memo) } end
min(list = @alt)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 51 def min list = @alt values = self[list] values.reduce(MAXINT){ |memo,v| (v<memo ? v : memo) } end
sum(list = @alt)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 56 def sum list = @alt values = self[list] values.reduce(0){ |memo,v| v+memo } end
to_ary()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 41 def to_ary @list end