BAM.Quality (BAM v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Parses a SAM QUAL field into raw BAM bytes.

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

Expands a missing QUAL into length bytes of 0xFF.

Formats raw BAM qualities as a SAM QUAL field.

Functions

from_sam(text)

@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?(arg)

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

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

missing_bytes(length)

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

Expands a missing QUAL into length bytes of 0xFF.

to_sam(raw)

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

Formats raw BAM qualities as a SAM QUAL field.