# `BAM.Index`
[🔗](https://github.com/baoulo/bam-elixir/blob/v0.1.0/lib/bam/index.ex#L1)

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.

# `chunk`

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

# `meta`

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

# `ref_entry`

```elixir
@type ref_entry() :: %{
  bins: %{
    optional(non_neg_integer()) =&gt; %{
      loff: non_neg_integer() | nil,
      chunks: [chunk()]
    }
  },
  linear: [non_neg_integer() | nil],
  meta: meta() | nil
}
```

# `t`

```elixir
@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()]
}
```

# `chunks`

```elixir
@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?`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
