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

Base qualities.

BAM stores one byte per base. The byte is a Phred score, not the
printable SAM character. A score of 0xFF in every byte means the
qualities are missing, which SAM writes as `*`.

SAM text can represent scores 0 through 93, because the stored character
is `score + 33` and must fall in the printable range `!` through `~`.
A BAM file may contain a higher score. Formatting such a record as SAM
returns an error so the score is not silently clamped. The raw bytes stay
on the alignment either way.

# `from_sam`

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

Parses a SAM QUAL field into raw BAM bytes.

`*` becomes an empty marker. Callers that know `l_seq` expand `*` to
`l_seq` bytes of 0xFF. A parsed string here is the scores themselves.

# `missing?`

```elixir
@spec missing?(binary()) :: boolean()
```

True when every byte is 0xFF, including the empty binary.

# `missing_bytes`

```elixir
@spec missing_bytes(non_neg_integer()) :: binary()
```

Expands a missing QUAL into `length` bytes of 0xFF.

# `to_sam`

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

Formats raw BAM qualities as a SAM QUAL field.

---

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