Class: HTS::VCF

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hts/vcf.rb,
lib/hts/vcf/header.rb,
lib/hts/vcf/variant.rb

Defined Under Namespace

Classes: Header, Variant

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, mode = 'r') ⇒ VCF

Returns a new instance of VCF.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hts/vcf.rb', line 14

def initialize(file_path, mode = 'r')
  @file_path = File.expand_path(file_path)
  File.exist?(@file_path) || raise("No such VCF/BCF file - #{@file_path}")

  @mode = mode
  @htf = FFI.hts_open(@file_path, mode)

  @header = VCF::Header.new(FFI.bcf_hdr_read(@htf))

  @c = FFI.bcf_init
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



12
13
14
# File 'lib/hts/vcf.rb', line 12

def file_path
  @file_path
end

#headerObject (readonly)

Returns the value of attribute header.



12
13
14
# File 'lib/hts/vcf.rb', line 12

def header
  @header
end

#htfObject (readonly)

Returns the value of attribute htf.



12
13
14
# File 'lib/hts/vcf.rb', line 12

def htf
  @htf
end

#modeObject (readonly)

Returns the value of attribute mode.



12
13
14
# File 'lib/hts/vcf.rb', line 12

def mode
  @mode
end

Instance Method Details

#each(&block) ⇒ Object

def inspect; end



28
29
30
# File 'lib/hts/vcf.rb', line 28

def each(&block)
  block.call(Variant.new(@c, self)) while FFI.bcf_read(@htf, @header.h, @c) != -1
end

#n_samplesObject



34
35
36
# File 'lib/hts/vcf.rb', line 34

def n_samples
  FFI.bcf_hdr_nsamples(header.h)
end

#seq(tid) ⇒ Object



32
# File 'lib/hts/vcf.rb', line 32

def seq(tid); end