Class: HTS::VCF

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

Defined Under Namespace

Classes: Format, Header, Info, Record

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
25
# File 'lib/hts/vcf.rb', line 14

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

  @file_path = file_path
  @mode      = mode
  @htf       = LibHTS.hts_open(file_path, mode)
  @header = VCF::Header.new(LibHTS.bcf_hdr_read(htf))

  # FIXME: should be defined here?
  @c = LibHTS.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



29
30
31
32
33
34
# File 'lib/hts/vcf.rb', line 29

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

#n_samplesObject



38
39
40
# File 'lib/hts/vcf.rb', line 38

def n_samples
  LibHTS.bcf_hdr_nsamples(header.h)
end

#seq(tid) ⇒ Object



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

def seq(tid); end