bamindexread

Read BAM Index, BAI, file

Syntax

Index = bamindexread(File)

Description

Index = bamindexread(File) reads File, a BAI file, and returns Index, a MATLAB® structure that specifies the offsets into the compressed Binary Sequence Alignment/Map (BAM) file and decompressed data block for each reference sequence and range of positions (bins) on each reference sequence.

Input Arguments

File

Character vector or string specifying a file name, or a path and a file name, of a BAM file or a BAI file. If File is a BAM file, bamindexread reads the corresponding BAI file, that is, the BAI file with the same root name and stored in the same folder as the BAM file. If you specify only a file name, that file must be on the MATLAB search path or in the Current Folder.

Output Arguments

Index

MATLAB array of structures that specifies the offsets into the compressed Binary Sequence Alignment/Map (BAM) file and decompressed data block for each reference sequence and range of positions (bins) on the reference sequence. Index contains the following fields.

FieldDescription
Filename

Name of the BAM file or BAI file used to create the Index array of structures.

Index

A 1-by-N array of structures, where N is the number of reference sequences in the corresponding BAM file. Each structure contains the following fields:

  • BinID — Array of bin IDs for one reference sequence.

  • BGZFOffsetStart — Offset in the BAM file to the start of the first BGZF block where alignment records associated with the corresponding BinID are stored.

  • BGZFOffsetEnd — Offset in the BAM file to the start of the last BGZF block where alignment records associated with the corresponding BinID are stored.

  • DataOffsetStart — Offset in the decompressed data block to the start of where alignment records associated with the corresponding BinID are stored.

  • DataOffsetEnd — Offset in the decompressed data block to the end of where alignment records associated with the corresponding BinID are stored.

  • LinearBGZFOffset — Offset in the BAM file to the first alignment in the corresponding 16384 bp interval.

  • LinearDataOffset — Offset in the decompressed data file to the first alignment in the corresponding 16384 bp interval.

Examples

collapse all

This example shows how to generate an index structure from a BAM index file.

ind = bamindexread('ex1.bam')
ind = struct with fields:
    Filename: 'ex1.bam.bai'
       Index: [1x2 struct]

Introduced in R2010b