class BioVcf::VcfGenotypeField
Attributes
format[R]
header[R]
values[R]
Public Class Methods
new(s, format, header, ref, alt)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 107 def initialize s, format, header, ref, alt @is_empty = VcfSample::empty?(s) @original_s = s @format = format @header = header @ref = ref @alt = alt end
Public Instance Methods
ad()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 135 def ad ilist('AD') end
amq()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 150 def amq VcfAltInfoList.new(@alt,values[fetch('AMQ')]) end
bcount()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 142 def bcount VcfNucleotideCount4.new(@alt,values[fetch('BCOUNT')]) end
bq()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 146 def bq VcfAltInfoList.new(@alt,values[fetch('BQ')]) end
dp4()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 132 def dp4 ilist('DP4') end
empty?()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 124 def empty? @is_empty end
gti()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 158 def gti gt.split(/[\/\|]/).map { |g| g.to_i } end
gti?()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 154 def gti? not VcfValue::empty?(fetch_value("GT")) end
gts()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 166 def gts genotypes = [@ref] + @alt gti.map { |i| genotypes[i] } end
gts?()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 162 def gts? not VcfValue::empty?(fetch_value("GT")) end
method_missing(m, *args, &block)
click to toggle source
Returns the value of a field
# File lib/bio-vcf/vcfgenotypefield.rb, line 172 def method_missing(m, *args, &block) return nil if @is_empty if m =~ /\?$/ # query if a value exists, e.g., r.info.dp? or s.dp? v = values[fetch(m.to_s.upcase.chop)] return (not VcfValue::empty?(v)) else v = values[fetch(m.to_s.upcase)] return nil if VcfValue::empty?(v) return v.to_i if v =~ /^\d+$/ return v.to_f if v =~ /^\d+\.\d+$/ v end end
pl()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 138 def pl ilist('PL') end
to_s()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 116 def to_s @original_s end
valid?()
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 128 def valid? !empty? end
Private Instance Methods
fetch(name)
click to toggle source
Fetch a value and throw an error if it does not exist
# File lib/bio-vcf/vcfgenotypefield.rb, line 190 def fetch name raise "ERROR: Field with name #{name} does not exist!" if !@format[name] @format[name] end
fetch_value(name)
click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 195 def fetch_value name values[fetch(name)] end
ilist(name)
click to toggle source
Return an integer list
# File lib/bio-vcf/vcfgenotypefield.rb, line 200 def ilist name v = fetch_value(name) return nil if not v v.split(',').map{|i| i.to_i} end