BAM.Index (BAM v0.1.0)

Copy Markdown View Source

In-memory BAI or CSI index.

Each reference has a map of bin numbers to chunks. A chunk is a half-open range of virtual offsets. The pseudo-bin that stores mapped and unmapped counts is kept on :meta and is not used as a seek range. BAI references also carry a linear index. An entry of nil in that list means the all-ones sentinel: no alignment has been observed in that 16 kbp window.

min_shift and depth are 14 and 5 for BAI. CSI records the pair it was built with. A reference whose length is greater than 2^29 does not fit in BAI.

Summary

Functions

Chunks of reference that can overlap the half-open interval [start, stop).

True when this index can address a reference of length bases.

Types

chunk()

@type chunk() :: %{beg: non_neg_integer(), end: non_neg_integer()}

meta()

@type meta() :: %{
  beg: non_neg_integer() | nil,
  end: non_neg_integer() | nil,
  mapped: non_neg_integer(),
  unmapped: non_neg_integer()
}

ref_entry()

@type ref_entry() :: %{
  bins: %{
    optional(non_neg_integer()) => %{
      loff: non_neg_integer() | nil,
      chunks: [chunk()]
    }
  },
  linear: [non_neg_integer() | nil],
  meta: meta() | nil
}

t()

@type t() :: %BAM.Index{
  aux: binary(),
  depth: non_neg_integer(),
  format: :bai | :csi,
  min_shift: non_neg_integer(),
  n_no_coor: non_neg_integer(),
  references: [ref_entry()]
}

Functions

chunks(index, ref_id, start, stop)

@spec chunks(t(), non_neg_integer(), non_neg_integer(), non_neg_integer()) ::
  {:ok, [chunk()]} | {:error, BAM.Error.t()}

Chunks of reference that can overlap the half-open interval [start, stop).

covers?(index, length)

@spec covers?(t(), non_neg_integer()) :: boolean()

True when this index can address a reference of length bases.