Class: HTS::Bcf::Header

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

Instance Method Summary collapse

Constructor Details

#initialize(hts_file) ⇒ Header

Returns a new instance of Header.



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

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

Instance Method Details

#get_versionObject



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

def get_version
  LibHTS.bcf_hdr_get_version(@bcf_hdr)
end

#sample_countObject



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

def sample_count
  LibHTS.bcf_hdr_nsamples(@bcf_hdr)
end

#sample_namesObject



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

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

#structObject



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

def struct
  @bcf_hdr
end

#to_ptrObject



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

def to_ptr
  @bcf_hdr.to_ptr
end

#to_sObject



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

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