Class: VCF::Variant

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#altObject (readonly)

Returns the value of attribute alt.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def alt
  @alt
end

#chromObject (readonly)

Returns the value of attribute chrom.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def chrom
  @chrom
end

#filterObject (readonly)

Returns the value of attribute filter.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def filter
  @filter
end

#idObject (readonly)

Returns the value of attribute id.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def id
  @id
end

#infoObject (readonly)

Returns the value of attribute info.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def info
  @info
end

#posObject (readonly)

Returns the value of attribute pos.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def pos
  @pos
end

#qualObject (readonly)

Returns the value of attribute qual.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def qual
  @qual
end

#refObject (readonly)

Returns the value of attribute ref.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def ref
  @ref
end

#sample_dataObject (readonly)

Returns the value of attribute sample_data.



67
68
69
# File 'lib/exodb/vcf.rb', line 67

def sample_data
  @sample_data
end

#strObject (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