Class: VCF

Inherits:
Object
  • Object
show all
Defined in:
lib/exodb/vcf.rb

Defined Under Namespace

Classes: Variant

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVCF

Returns a new instance of VCF.



7
8
9
10
11
12
13
14
15
16
# File 'lib/exodb/vcf.rb', line 7

def initialize()
	@info_attr = {}
	@filter_attr = {}
	@format_attr = {}
	@alt_attr = {}
	@meta = {}
	@contig = {}
	@variants = []

end

Instance Attribute Details

#alt_attrObject (readonly)

Returns the value of attribute alt_attr.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def alt_attr
  @alt_attr
end

#contigObject (readonly)

Returns the value of attribute contig.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def contig
  @contig
end

#filter_attrObject (readonly)

Returns the value of attribute filter_attr.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def filter_attr
  @filter_attr
end

#format_attrObject (readonly)

Returns the value of attribute format_attr.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def format_attr
  @format_attr
end

#info_attrObject (readonly)

Returns the value of attribute info_attr.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def info_attr
  @info_attr
end

#metaObject (readonly)

Returns the value of attribute meta.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def meta
  @meta
end

#samplesObject (readonly)

Returns the value of attribute samples.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def samples
  @samples
end

#variantsObject (readonly)

Returns the value of attribute variants.



5
6
7
# File 'lib/exodb/vcf.rb', line 5

def variants
  @variants
end

Instance Method Details

#fileformatObject



44
45
46
# File 'lib/exodb/vcf.rb', line 44

def fileformat
	return @meta[:fileformat]
end

#open(filename) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/exodb/vcf.rb', line 18

def open(filename)
	
	File.open(filename).each do |line|
		case line
		when /^##INFO/
			parse_info(line.chomp)
		when /^##FORMAT/
			parse_format(line.chomp)
		when /^##FILTER/
			parse_filter(line.chomp)
		when /^##contig/
			parse_contig(line.chomp)
		when /^##ALT/
			parse_alt(line.chomp)
		when /^##/
			parse_meta(line.chomp)
		when /^#/
			@samples = line.split(/\s+/)[9..-1]
		else
			@variants.push(Variant.new(line.chomp))
		end
		
	end
	
end

#parse(line = 4000) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/exodb/vcf.rb', line 48

def parse(line = 4000)
	@variants.each_index do |ind|
		break if ind > line
		Thread.new (ind) {
			@variants[ind].parse!(@info_attr, @format_attr)
		}
	end
end

#sample_numObject



57
58
59
# File 'lib/exodb/vcf.rb', line 57

def sample_num
	return @samples.length
end

#variant_numObject



61
62
63
# File 'lib/exodb/vcf.rb', line 61

def variant_num
	return @variants.length
end