Class: Bio::Bam::SamHeader

Inherits:
Object
  • Object
show all
Includes:
SambambaStderrParser
Defined in:
lib/bio-sambamba/samheader.rb

Overview

Represents SAM header

Instance Method Summary collapse

Constructor Details

#initialize(filename, opts = []) ⇒ SamHeader

Creates a new SamHeader object for a specified file, specifying additional options to pass to sambamba tool



10
11
12
13
# File 'lib/bio-sambamba/samheader.rb', line 10

def initialize(filename, opts=[])
  @filename = filename
  @opts = opts
end

Instance Method Details

#pg_linesObject

An array of PGLine objects



48
49
50
# File 'lib/bio-sambamba/samheader.rb', line 48

def pg_lines
  @pg_lines ||= obj[4].map{|rec| PGLine.new(rec)}
end

#raw_contentsObject

Raw text of SAM header



16
17
18
19
20
21
22
23
24
25
# File 'lib/bio-sambamba/samheader.rb', line 16

def raw_contents
  if @raw_contents.nil? then
    cmd = ['sambamba', 'view', '-H', @filename] + @opts
    Bio::Command.call_command_open3(cmd) do |pin, pout, perr|
      @raw_contents = pout.read
      raise_exception_if_stderr_is_not_empty(perr)
    end
  end
  @raw_contents
end

#rg_linesObject

An array of RGLine objects



43
44
45
# File 'lib/bio-sambamba/samheader.rb', line 43

def rg_lines
  @rg_lines ||= obj[3].map{|rec| RGLine.new(rec)}
end

#sorting_orderObject

Sorting order



33
34
35
# File 'lib/bio-sambamba/samheader.rb', line 33

def sorting_order
  obj[1]
end

#sq_linesObject

An array of SQLine objects



38
39
40
# File 'lib/bio-sambamba/samheader.rb', line 38

def sq_lines
  @sq_lines ||= obj[2].map{|rec| SQLine.new(rec)}
end

#versionObject

Format version



28
29
30
# File 'lib/bio-sambamba/samheader.rb', line 28

def version
  obj[0]
end