Class: Bio::Bam::File
- Inherits:
-
Object
- Object
- Bio::Bam::File
- Defined in:
- lib/bio-sambamba/bamfile.rb
Overview
Class providing access to BAM files
Instance Method Summary collapse
-
#alignments ⇒ Object
Returns an AlignmentIterator object for iterating over all alignments in the file.
-
#fetch(chr, region) ⇒ Object
Fetches alignments overlapping a region.
-
#has_index? ⇒ Boolean
True if index file was found.
-
#header ⇒ Object
SAM header.
-
#initialize(filename) ⇒ File
constructor
Creates an object for access to BAM file.
Constructor Details
#initialize(filename) ⇒ File
Creates an object for access to BAM file
10 11 12 |
# File 'lib/bio-sambamba/bamfile.rb', line 10 def initialize(filename) @filename = filename end |
Instance Method Details
#alignments ⇒ Object
Returns an AlignmentIterator object for iterating over all alignments in the file
20 21 22 |
# File 'lib/bio-sambamba/bamfile.rb', line 20 def alignments Bio::Bam::AlignmentIterator.new ['sambamba', 'view', '--format=json', @filename] end |
#fetch(chr, region) ⇒ Object
Fetches alignments overlapping a region. Returns an AlignmentIterator object.
Arguments:
-
chr: reference sequence
-
region: a Range representing an interval. Coordinates are 1-based.
37 38 39 40 41 |
# File 'lib/bio-sambamba/bamfile.rb', line 37 def fetch(chr, region) Bio::Bam::AlignmentIterator.new ['sambamba', 'view', '--format=json', @filename, "#{chr}:#{region.min}-#{region.max}"] end |