Class: HTS::Bam::Pileup::PileupRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/hts/bam/pileup.rb

Overview

A wrapper of one bam_pileup1_t entry

Instance Method Summary collapse

Constructor Details

#initialize(entry, header) ⇒ PileupRecord

Returns a new instance of PileupRecord.



34
35
36
37
38
# File 'lib/hts/bam/pileup.rb', line 34

def initialize(entry, header)
  @entry  = entry
  @header = header
  @record = nil
end

Instance Method Details

#del?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/hts/bam/pileup.rb', line 64

def del?
  @entry[:is_del] == 1
end

#head?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/hts/bam/pileup.rb', line 68

def head?
  @entry[:is_head] == 1
end

#indelObject



60
61
62
# File 'lib/hts/bam/pileup.rb', line 60

def indel
  @entry[:indel]
end

#query_positionObject



56
57
58
# File 'lib/hts/bam/pileup.rb', line 56

def query_position
  @entry[:qpos]
end

#recordObject

Return Bam::Record. On the first call, duplicate the underlying bam1_t (bam_dup1) so the record becomes safe to keep beyond the current pileup step. Subsequent calls return the cached Bam::Record instance. NOTE: Without duplication, bam1_t memory may be reused by HTSlib on the next step.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hts/bam/pileup.rb', line 44

def record
  return @record if @record

  # Normalize to a raw pointer and duplicate to obtain owned memory.
  b_ptr = @entry[:b].is_a?(FFI::Pointer) ? @entry[:b] : @entry[:b].to_ptr
  dup_ptr = HTS::LibHTS.bam_dup1(b_ptr)
  raise "bam_dup1 failed" if dup_ptr.null?

  # Build a Bam::Record backed by the duplicated bam1_t.
  @record = HTS::Bam::Record.new(@header, dup_ptr)
end

#refskip?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/hts/bam/pileup.rb', line 76

def refskip?
  @entry[:is_refskip] == 1
end

#tail?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/hts/bam/pileup.rb', line 72

def tail?
  @entry[:is_tail] == 1
end