Class: HTS::Bcf::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/hts/bcf/header.rb

Overview

A class for working with VCF records.

Instance Method Summary collapse

Constructor Details

#initialize(hts_file) ⇒ Header

Returns a new instance of Header.



7
8
9
# File 'lib/hts/bcf/header.rb', line 7

def initialize(hts_file)
  @bcf_hdr = LibHTS.bcf_hdr_read(hts_file)
end

Instance Method Details

#get_versionObject



19
20
21
# File 'lib/hts/bcf/header.rb', line 19

def get_version
  LibHTS.bcf_hdr_get_version(@bcf_hdr)
end

#nsamplesObject



23
24
25
# File 'lib/hts/bcf/header.rb', line 23

def nsamples
  LibHTS.bcf_hdr_nsamples(@bcf_hdr)
end

#samplesObject



27
28
29
30
31
32
# File 'lib/hts/bcf/header.rb', line 27

def samples
  # bcf_hdr_id2name is macro function
  @bcf_hdr[:samples]
    .read_array_of_pointer(nsamples)
    .map(&:read_string)
end

#structObject



11
12
13
# File 'lib/hts/bcf/header.rb', line 11

def struct
  @bcf_hdr
end

#to_ptrObject



15
16
17
# File 'lib/hts/bcf/header.rb', line 15

def to_ptr
  @bcf_hdr.to_ptr
end

#to_sObject



34
35
36
37
38
39
# File 'lib/hts/bcf/header.rb', line 34

def to_s
  kstr = LibHTS::KString.new
  raise "Failed to get header string" unless LibHTS.bcf_hdr_format(@bcf_hdr, 0, kstr)

  kstr[:s]
end