module BioVcf MAXINT=100_000 # Helper class for a list of (variant) values, such as A,G. # The [] function does the hard work (see ./features for examples) class VcfNucleotides def initialize alt,list @alt = alt @list = list.map{|i| i.to_i} end def [] idx if idx.kind_of?(Integer) @list[idx].to_i elsif idx.kind_of?(String) @list[["A","C","G","T"].index(idx)].to_i else idx.kind_of?(Array) idx.map { |nuc| idx2 = ["A","C","G","T"].index(nuc) # p [idx,nuc,idx2,@list] @list[idx2].to_i } end end def to_ary @list end # Return the max value on the nucleotides in the list (typically rec.alt) def max list = @alt values = self[list] values.reduce(0){ |memo,v| (v>memo ? v : memo) } end def min list = @alt values = self[list] values.reduce(MAXINT){ |memo,v| (vmemo ? v : memo) } end def min @list.reduce(MAXINT){ |memo,v| (v