Class: BioVcf::VcfRecordInfo
- Inherits:
-
Object
- Object
- BioVcf::VcfRecordInfo
show all
- Defined in:
- lib/bio-vcf/vcfrecord.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of VcfRecordInfo.
4
5
6
|
# File 'lib/bio-vcf/vcfrecord.rb', line 4
def initialize s
@info = s
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
51
52
53
|
# File 'lib/bio-vcf/vcfrecord.rb', line 51
def method_missing(m, *args, &block)
self[m.to_s]
end
|
Instance Method Details
#[](k) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/bio-vcf/vcfrecord.rb', line 16
def [] k
kupper = k.upcase
v = if @h
@h[kupper]
else
@info =~ /[\A;]#{k}=([^;]+)/i
value = $1
if value == nil
split_fields
@h[kupper]
else
value
end
end
ConvertStringToValue::convert(v)
end
|
#[]=(k, v) ⇒ Object
Set INFO fields (used by –rewrite)
39
40
41
42
43
44
|
# File 'lib/bio-vcf/vcfrecord.rb', line 39
def []= k, v
split_fields if not @h
kupper = k.upcase
@h[kupper] = v
@original_key[kupper] = k
end
|
#fields ⇒ Object
46
47
48
49
|
# File 'lib/bio-vcf/vcfrecord.rb', line 46
def fields
split_fields
@h.keys
end
|
#to_s ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/bio-vcf/vcfrecord.rb', line 8
def to_s
if @h
@h.map { |k,v| (v ? @original_key[k] + '=' + v : @original_key[k]) }.join(';')
else
@info
end
end
|