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

CSI index codec.

CSI generalises the BAI binning scheme. The file may be a raw `CSI\1`
stream or a BGZF compression of that stream. Each bin carries `loffset`,
the virtual offset of the leftmost record placed in the bin. The metadata
pseudo-bin number is `bin_limit(min_shift, depth) + 1`. This module reads
CSI and writes an uncompressed CSI payload. `compress/2` BGZF-compresses
that payload, which is the form HTSlib writes.

# `compress`

```elixir
@spec compress(BAM.Index.t(), keyword()) :: {:ok, binary()} | {:error, BAM.Error.t()}
```

Writes a BGZF-compressed CSI binary.

# `decode`

```elixir
@spec decode(binary(), BAM.Limits.t()) ::
  {:ok, BAM.Index.t()} | {:error, BAM.Error.t()}
```

Decodes a CSI binary or a BGZF-compressed CSI file.

# `encode`

```elixir
@spec encode(BAM.Index.t()) :: {:ok, binary()} | {:error, BAM.Error.t()}
```

Encodes the uncompressed CSI payload.

---

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