class HTS::Bam::Record

Constants

SEQ_NT16_STR

Public Class Methods

new(bam1_t, bam_hdr_t) click to toggle source
# File lib/hts/bam/record.rb, line 11
def initialize(bam1_t, bam_hdr_t)
  @b = bam1_t
  @h = bam_hdr_t
end
rom_sam_str() click to toggle source

def initialize_copy

super

end

# File lib/hts/bam/record.rb, line 20
def self.rom_sam_str; end

Public Instance Methods

base_at(n) click to toggle source

return only the base of the requested index ā€œiā€ of the query sequence.

# File lib/hts/bam/record.rb, line 124
def base_at(n)
  n += @b[:core][:l_qseq] if n < 0
  return "." if (n >= @b[:core][:l_qseq]) || (n < 0) # eg. base_at(-1000)

  r = LibHTS.bam_get_seq(@b)
  SEQ_NT16_STR[LibHTS.bam_seqi(r, n)]
end
base_qualities() click to toggle source

return the base qualities

# File lib/hts/bam/record.rb, line 133
def base_qualities
  q_ptr = LibHTS.bam_get_qual(@b)
  q_ptr.read_array_of_uint8(@b[:core][:l_qseq])
end
base_quality_at(n) click to toggle source

return only the base quality of the requested index ā€œiā€ of the query sequence.

# File lib/hts/bam/record.rb, line 139
def base_quality_at(n)
  n += @b[:core][:l_qseq] if n < 0
  return 0 if (n >= @b[:core][:l_qseq]) || (n < 0) # eg. base_quality_at(-1000)

  q_ptr = LibHTS.bam_get_qual(@b)
  q_ptr.get_uint8(n)
end
chrom() click to toggle source

returns the chromosome or '' if not mapped.

# File lib/hts/bam/record.rb, line 61
def chrom
  tid = @b[:core][:tid]
  return "" if tid == -1

  LibHTS.sam_hdr_tid2name(@h, tid)
end
cigar() click to toggle source

returns a `Cigar` object.

# File lib/hts/bam/record.rb, line 95
def cigar
  Cigar.new(LibHTS.bam_get_cigar(@b), @b[:core][:n_cigar])
end
flag() click to toggle source

returns a `Flag` object.

# File lib/hts/bam/record.rb, line 152
def flag
  Flag.new(@b[:core][:flag])
end
flag_str() click to toggle source
# File lib/hts/bam/record.rb, line 147
def flag_str
  LibHTS.bam_flag2str(@b[:core][:flag])
end
isize() click to toggle source

insert size

# File lib/hts/bam/record.rb, line 85
def isize
  @b[:core][:isize]
end
mapping_quality() click to toggle source

mapping quality

# File lib/hts/bam/record.rb, line 90
def mapping_quality
  @b[:core][:qual]
end
mate_chrom() click to toggle source

returns the chromosome of the mate or '' if not mapped.

# File lib/hts/bam/record.rb, line 69
def mate_chrom
  tid = @b[:core][:mtid]
  return "" if tid == -1

  LibHTS.sam_hdr_tid2name(@h, tid)
end
mate_pos()
Alias for: mate_start
mate_start() click to toggle source

returns 0-based mate position

# File lib/hts/bam/record.rb, line 55
def mate_start
  @b[:core][:mpos]
end
Also aliased as: mate_pos
mate_tid() click to toggle source

returns the tid of the mate or -1 if not mapped.

# File lib/hts/bam/record.rb, line 40
def mate_tid
  @b[:core][:mtid]
end
qlen() click to toggle source
# File lib/hts/bam/record.rb, line 99
def qlen
  LibHTS.bam_cigar2qlen(
    @b[:core][:n_cigar],
    LibHTS.bam_get_cigar(@b)
  )
end
qname() click to toggle source

returns the query name.

# File lib/hts/bam/record.rb, line 25
def qname
  LibHTS.bam_get_qname(@b).read_string
end
rlen() click to toggle source
# File lib/hts/bam/record.rb, line 106
def rlen
  LibHTS.bam_cigar2rlen(
    @b[:core][:n_cigar],
    LibHTS.bam_get_cigar(@b)
  )
end
sequence() click to toggle source

return the read sequence

# File lib/hts/bam/record.rb, line 114
def sequence
  r = LibHTS.bam_get_seq(@b)
  seq = String.new
  (@b[:core][:l_qseq]).times do |i|
    seq << SEQ_NT16_STR[LibHTS.bam_seqi(r, i)]
  end
  seq
end
start() click to toggle source

returns 0-based start position.

# File lib/hts/bam/record.rb, line 45
def start
  @b[:core][:pos]
end
stop() click to toggle source

returns end position of the read.

# File lib/hts/bam/record.rb, line 50
def stop
  LibHTS.bam_endpos @b
end
strand() click to toggle source
# File lib/hts/bam/record.rb, line 76
def strand
  LibHTS.bam_is_rev(@b) ? "-" : "+"
end
tags() click to toggle source
# File lib/hts/bam/record.rb, line 22
def tags; end
tid() click to toggle source

returns the tid of the record or -1 if not mapped.

# File lib/hts/bam/record.rb, line 35
def tid
  @b[:core][:tid]
end