Class: Bio::Sam::File
- Inherits:
-
Object
- Object
- Bio::Sam::File
- Includes:
- FileExistenceChecker
- Defined in:
- lib/bio-sambamba/samfile.rb
Overview
Class providing access to SAM files
Instance Method Summary collapse
-
#alignments ⇒ Object
Returns an AlignmentIterator object for iterating over all alignments in the file.
-
#header ⇒ Object
SAM header.
-
#initialize(filename) ⇒ File
constructor
Creates an object for access to SAM file.
- #reference_sequences ⇒ Object
Methods included from FileExistenceChecker
Constructor Details
#initialize(filename) ⇒ File
Creates an object for access to SAM file
11 12 13 14 |
# File 'lib/bio-sambamba/samfile.rb', line 11 def initialize(filename) @filename = filename check_file_existence filename end |
Instance Method Details
#alignments ⇒ Object
Returns an AlignmentIterator object for iterating over all alignments in the file
22 23 24 25 |
# File 'lib/bio-sambamba/samfile.rb', line 22 def alignments cmdline = ['sambamba', 'view', '--format', 'msgpack', '-S', @filename], Bio::Bam::AlignmentIterator.new(cmdline, reference_sequences) end |
#header ⇒ Object
SAM header
17 18 19 |
# File 'lib/bio-sambamba/samfile.rb', line 17 def header @header ||= Bio::Bam::SamHeader.new(@filename, ['-S']) end |
#reference_sequences ⇒ Object
27 28 29 |
# File 'lib/bio-sambamba/samfile.rb', line 27 def reference_sequences @reference_sequences ||= Oj.load(Bio::Command.query_command ['sambamba', 'view', '-I', '-S', @filename]) end |