Class: BioVcf::VcfGenotypeField
- Inherits:
-
Object
- Object
- BioVcf::VcfGenotypeField
show all
- Defined in:
- lib/bio-vcf/vcfgenotypefield.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(s, format, header, ref, alt) ⇒ VcfGenotypeField
Returns a new instance of VcfGenotypeField.
107
108
109
110
111
112
113
114
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 107
def initialize s, format, , ref, alt
@is_empty = VcfSample::empty?(s)
@original_s = s
@format = format
@header =
@ref = ref
@alt = alt
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
Returns the value of a field
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 172
def method_missing(m, *args, &block)
return nil if @is_empty
if m =~ /\?$/
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)
v = v.to_i if v =~ /^\d+$/
v = v.to_f if v =~ /^\d+\.\d+$/
v
end
end
|
Instance Attribute Details
Returns the value of attribute format.
105
106
107
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 105
def format
@format
end
|
Returns the value of attribute header.
105
106
107
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 105
def
@header
end
|
#values ⇒ Object
Returns the value of attribute values.
105
106
107
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 105
def values
@values
end
|
Instance Method Details
#ad ⇒ Object
135
136
137
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 135
def ad
ilist('AD')
end
|
#amq ⇒ Object
150
151
152
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 150
def amq
VcfAltInfoList.new(@alt,values[fetch('AMQ')])
end
|
#bcount ⇒ Object
142
143
144
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 142
def bcount
VcfNucleotideCount4.new(@alt,values[fetch('BCOUNT')])
end
|
#bq ⇒ Object
146
147
148
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 146
def bq
VcfAltInfoList.new(@alt,values[fetch('BQ')])
end
|
#dp4 ⇒ Object
132
133
134
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 132
def dp4
ilist('DP4')
end
|
#empty? ⇒ Boolean
124
125
126
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 124
def empty?
@is_empty
end
|
#gti ⇒ Object
158
159
160
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 158
def gti
gt.split(/[\/\|]/).map { |g| g.to_i }
end
|
#gti? ⇒ Boolean
154
155
156
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 154
def gti?
not VcfValue::empty?(fetch_value("GT"))
end
|
#gts ⇒ Object
166
167
168
169
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 166
def gts
genotypes = [@ref] + @alt
gti.map { |i| genotypes[i] }
end
|
#gts? ⇒ Boolean
162
163
164
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 162
def gts?
not VcfValue::empty?(fetch_value("GT"))
end
|
#pl ⇒ Object
138
139
140
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 138
def pl
ilist('PL')
end
|
#to_s ⇒ Object
116
117
118
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 116
def to_s
@original_s
end
|
#valid? ⇒ Boolean
128
129
130
|
# File 'lib/bio-vcf/vcfgenotypefield.rb', line 128
def valid?
!empty?
end
|