class BioVcf::VcfGenotypeFields

Holds all samples

Public Class Methods

new(fields, format, header, ref, alt) click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 210
def initialize fields, format, header, ref, alt
  @fields = fields
  @format = format
  @header = header
  @ref = ref
  @alt = alt
  @samples = {} # lazy cache
  @sample_index = @header.sample_index()
end

Public Instance Methods

[](name) click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 220
def [] name
  begin
    @samples[name] ||= VcfGenotypeField.new(@fields[@sample_index[name]],@format,@header,@ref,@alt)
  rescue TypeError
    $stderr.print "Unknown field name <#{name}> in record, did you mean r.info.#{name}?\n"
    raise
  end
end
method_missing(m, *args, &block) click to toggle source
# File lib/bio-vcf/vcfgenotypefield.rb, line 229
def method_missing(m, *args, &block)
  name = m.to_s
  if name =~ /\?$/
    # test for valid sample
    return !VcfSample::empty?(@fields[@sample_index[name.chop]])
  else
    @samples[name] ||= VcfGenotypeField.new(@fields[@sample_index[name]],@format,@header,@ref,@alt)
  end
end