Class: VCF::Variant
- Inherits:
-
Object
- Object
- VCF::Variant
- Defined in:
- lib/exodb/vcf.rb
Constant Summary collapse
- CASTING =
lambda do |string, type| case type when 'Integer' return string.to_i when 'Float' return string.to_f else return string.to_s end end
Instance Attribute Summary collapse
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#chrom ⇒ Object
readonly
Returns the value of attribute chrom.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
-
#qual ⇒ Object
readonly
Returns the value of attribute qual.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#sample_data ⇒ Object
readonly
Returns the value of attribute sample_data.
-
#str ⇒ Object
readonly
Returns the value of attribute str.
Instance Method Summary collapse
-
#initialize(str) ⇒ Variant
constructor
A new instance of Variant.
- #parse!(info_attr, format_attr) ⇒ Object
Constructor Details
#initialize(str) ⇒ Variant
Returns a new instance of Variant.
80 81 82 |
# File 'lib/exodb/vcf.rb', line 80 def initialize(str) @str = str end |
Instance Attribute Details
#alt ⇒ Object (readonly)
Returns the value of attribute alt.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def alt @alt end |
#chrom ⇒ Object (readonly)
Returns the value of attribute chrom.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def chrom @chrom end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def filter @filter end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def info @info end |
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def pos @pos end |
#qual ⇒ Object (readonly)
Returns the value of attribute qual.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def qual @qual end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def ref @ref end |
#sample_data ⇒ Object (readonly)
Returns the value of attribute sample_data.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def sample_data @sample_data end |
#str ⇒ Object (readonly)
Returns the value of attribute str.
67 68 69 |
# File 'lib/exodb/vcf.rb', line 67 def str @str end |
Instance Method Details
#parse!(info_attr, format_attr) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/exodb/vcf.rb', line 84 def parse!(info_attr, format_attr) if @str splited = str.split(/\s+/) @chrom = splited[0] @pos = splited[1].to_i @id = splited[2] @ref = splited[3] @alt = splited[4] @qual = splited[5] @filter = splited[6] @info = {} parse_info(splited[7], info_attr) @formats = splited[8].split(/:/) @sample_data = [] splited[9..-1].each {|data| @sample_data.push(parse_format(data, @formats, format_attr))} @str = nil end end |