Class: VCF::Genotype
- Inherits:
-
Object
show all
- Defined in:
- lib/vcf.rb
Instance Method Summary
collapse
Constructor Details
#initialize(line, field) ⇒ Genotype
Returns a new instance of Genotype.
113
114
115
116
|
# File 'lib/vcf.rb', line 113
def initialize(line,field)
@line = line
@hash = Hash[line.format.map(&:downcase).zip(field.split /:/)]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
118
119
120
121
122
123
124
125
126
|
# File 'lib/vcf.rb', line 118
def method_missing sym, *args, &block
if @hash[sym]
@hash[sym]
elsif sym.to_s =~ /(.*)=/
@hash[$1.to_sym] = args.first
else
super sym, *args, &block
end
end
|
Instance Method Details
#alt_base_quality ⇒ Object
156
|
# File 'lib/vcf.rb', line 156
def alt_base_quality; respond_to?(:nqsbq) ? nqsbq.split(/,/)[0].to_f : nil; end
|
#alt_count ⇒ Object
150
|
# File 'lib/vcf.rb', line 150
def alt_count; @alt_count ||= respond_to?(:ad) ? ad.split(/,/)[1].to_i : nil; end
|
#alt_freq ⇒ Object
152
|
# File 'lib/vcf.rb', line 152
def alt_freq; alt_count / depth.to_f; end
|
#alt_length ⇒ Object
155
|
# File 'lib/vcf.rb', line 155
def alt_length; @line.alt.length; end
|
#alt_map_quality ⇒ Object
157
|
# File 'lib/vcf.rb', line 157
def alt_map_quality; respond_to?(:mqs) ? mqs.split(/,/)[0].to_f : nil; end
|
#alt_mismatch_count ⇒ Object
159
|
# File 'lib/vcf.rb', line 159
def alt_mismatch_count; respond_to?(:mm) ? mm.split(/,/)[0].to_f : nil; end
|
#alt_mismatch_rate ⇒ Object
158
|
# File 'lib/vcf.rb', line 158
def alt_mismatch_rate; respond_to?(:nqsmm) ? nqsmm.split(/,/)[0].to_f : nil; end
|
#approx_depth ⇒ Object
148
|
# File 'lib/vcf.rb', line 148
def approx_depth; dp.to_i; end
|
#callable? ⇒ Boolean
144
145
146
|
# File 'lib/vcf.rb', line 144
def callable?
gt !~ /\..\./
end
|
#depth ⇒ Object
149
|
# File 'lib/vcf.rb', line 149
def depth; alt_count + ref_count; end
|
#empty? ⇒ Boolean
140
141
142
|
# File 'lib/vcf.rb', line 140
def empty?
gt =~ /\..\./
end
|
#heterozygous? ⇒ Boolean
136
137
138
|
# File 'lib/vcf.rb', line 136
def heterozygous?
gt =~ /0.1/ || gt =~ /1.0/
end
|
#homozygous? ⇒ Boolean
132
133
134
|
# File 'lib/vcf.rb', line 132
def homozygous?
gt =~ /0.0/ || gt =~ /1.1/
end
|
#quality ⇒ Object
160
|
# File 'lib/vcf.rb', line 160
def quality; gq.to_i; end
|
#ref_count ⇒ Object
151
|
# File 'lib/vcf.rb', line 151
def ref_count; @ref_count ||= respond_to?(:ad) ? ad.split(/,/)[0].to_i : nil; end
|
#ref_freq ⇒ Object
153
|
# File 'lib/vcf.rb', line 153
def ref_freq; ref_count / depth.to_f; end
|
#ref_length ⇒ Object
154
|
# File 'lib/vcf.rb', line 154
def ref_length; @line.ref.length; end
|
#respond_to_missing?(sym, include_all = false) ⇒ Boolean
128
129
130
|
# File 'lib/vcf.rb', line 128
def respond_to_missing? sym, include_all = false
@hash[sym] || super
end
|
#to_s ⇒ Object
162
163
164
|
# File 'lib/vcf.rb', line 162
def to_s
@line.format.map(&:downcase).map{|f| @hash[f]}.join(":")
end
|