class BioVcf::VcfAltInfoList
Handle info fields with multiple entries, possibly relating to ALT (single nucleotide only)
Public Class Methods
new(alt,list)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 66 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 71 def [] idx if idx.kind_of?(Integer) @list[idx].to_i elsif idx.kind_of?(String) @list[@alt.index(idx)].to_i else idx.kind_of?(Array) idx.map { |nuc| idx2 = @alt.index(nuc) # p [idx,nuc,idx2,@list] @list[idx2].to_i } end end
max()
click to toggle source
Return the max value on the nucleotides in the list (typically rec.alt)
# File lib/bio-vcf/vcfgenotypefield.rb, line 90 def max @list.reduce(0){ |memo,v| (v>memo ? v : memo) } end
min()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 94 def min @list.reduce(MAXINT){ |memo,v| (v<memo ? v : memo) } end
sum()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 98 def sum @list.reduce(0){ |memo,v| v+memo } end
to_ary()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 85 def to_ary @list end