Class: VCF
- Inherits:
-
Object
- Object
- VCF
- Defined in:
- lib/exodb/vcf.rb
Defined Under Namespace
Classes: Variant
Instance Attribute Summary collapse
-
#alt_attr ⇒ Object
readonly
Returns the value of attribute alt_attr.
-
#contig ⇒ Object
readonly
Returns the value of attribute contig.
-
#filter_attr ⇒ Object
readonly
Returns the value of attribute filter_attr.
-
#format_attr ⇒ Object
readonly
Returns the value of attribute format_attr.
-
#info_attr ⇒ Object
readonly
Returns the value of attribute info_attr.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#samples ⇒ Object
readonly
Returns the value of attribute samples.
-
#variants ⇒ Object
readonly
Returns the value of attribute variants.
Instance Method Summary collapse
- #fileformat ⇒ Object
-
#initialize ⇒ VCF
constructor
A new instance of VCF.
- #open(filename) ⇒ Object
- #parse(line = 4000) ⇒ Object
- #sample_num ⇒ Object
- #variant_num ⇒ Object
Constructor Details
#initialize ⇒ VCF
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_attr ⇒ Object (readonly)
Returns the value of attribute alt_attr.
5 6 7 |
# File 'lib/exodb/vcf.rb', line 5 def alt_attr @alt_attr end |
#contig ⇒ Object (readonly)
Returns the value of attribute contig.
5 6 7 |
# File 'lib/exodb/vcf.rb', line 5 def contig @contig end |
#filter_attr ⇒ Object (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_attr ⇒ Object (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_attr ⇒ Object (readonly)
Returns the value of attribute info_attr.
5 6 7 |
# File 'lib/exodb/vcf.rb', line 5 def info_attr @info_attr end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
5 6 7 |
# File 'lib/exodb/vcf.rb', line 5 def @meta end |
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
5 6 7 |
# File 'lib/exodb/vcf.rb', line 5 def samples @samples end |
#variants ⇒ Object (readonly)
Returns the value of attribute variants.
5 6 7 |
# File 'lib/exodb/vcf.rb', line 5 def variants @variants end |
Instance Method Details
#fileformat ⇒ Object
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 /^##/ (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_num ⇒ Object
57 58 59 |
# File 'lib/exodb/vcf.rb', line 57 def sample_num return @samples.length end |
#variant_num ⇒ Object
61 62 63 |
# File 'lib/exodb/vcf.rb', line 61 def variant_num return @variants.length end |