Class: BioVcf::VcfGenotypeField

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-vcf/vcfgenotypefield.rb

Instance Method Summary collapse

Constructor Details

#initialize(s, format, header, alt) ⇒ VcfGenotypeField

Returns a new instance of VcfGenotypeField.



89
90
91
92
93
94
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 89

def initialize s, format, header, alt
  @values = s.split(/:/)
  @format = format
  @header = header
  @alt = alt
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



120
121
122
123
124
125
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 120

def method_missing(m, *args, &block)  
  v = @values[@format[m.to_s.upcase]]
  v = v.to_i if v =~ /^\d+$/
  v = v.to_f if v =~ /^\d+\.\d+$/
  v
end

Instance Method Details

#adObject



100
101
102
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 100

def ad
  @values[@format['AD']].split(',').map{|i| i.to_i}
end

#amqObject



116
117
118
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 116

def amq
  VcfAltInfo.new(@alt,@values[@format['AMQ']].split(','))
end

#bcountObject



108
109
110
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 108

def bcount
  VcfNucleotides.new(@alt,@values[@format['BCOUNT']].split(','))
end

#bqObject



112
113
114
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 112

def bq
  VcfAltInfo.new(@alt,@values[@format['BQ']].split(','))
end

#dp4Object



96
97
98
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 96

def dp4
  @values[@format['DP4']].split(',').map{|i| i.to_i}
end

#plObject



104
105
106
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 104

def pl
  @values[@format['PL']].split(',').map{|i| i.to_i}
end