Class: Bio::Bam::SamHeader

Inherits:
Object
  • Object
show all
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



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

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

Instance Method Details

#pg_linesObject

An array of PGLine objects



50
51
52
53
# File 'lib/bio-sambamba/samheader.rb', line 50

def pg_lines
  @json ||= get_json
  @sq_lines ||= @json['pg_lines'].map{|json| PGLine.new(json)}
end

#raw_contentsObject

Raw text of SAM header



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

def raw_contents
  if @raw_contents.nil? then
    @raw_contents = Bio::Command.query_command(['sambamba', '-H', @filename] + @opts)
    if @raw_contents.start_with? "sambamba" then
      raise @raw_contents
    end
  end
  @raw_contents
end

#rg_linesObject

An array of RGLine objects



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

def rg_lines
  @json ||= get_json
  @sq_lines ||= @json['rg_lines'].map{|json| RGLine.new(json)}
end

#sorting_orderObject

Sorting order



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

def sorting_order
  @json ||= get_json
  @json['sorting_order']
end

#sq_linesObject

An array of SQLine objects



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

def sq_lines
  @json ||= get_json
  @sq_lines ||= @json['sq_lines'].map{|json| SQLine.new(json)}
end

#versionObject

Format version



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

def version
  @json ||= get_json
  @json['format_version']
end