Reference sequences from a local FASTA file.
A sibling .fai index is used when it contains the requested name. The
returned bases are checked against expected_md5 before they leave this
module. The default maximum sequence size is 64 MiB.
Summary
Types
@type t() :: %CRAM.Reference.Local{max_sequence_bytes: pos_integer(), path: Path.t()}
A FASTA file used as a reference.
:path— the FASTA path. A sibling.faiis consulted when present:max_sequence_bytes— largest sequence that will be returnediex> {:ok, local} = CRAM.Reference.Local.new("tutorials/fixtures/sq0.fa") iex> local.path "tutorials/fixtures/sq0.fa"
Functions
Return the bases for name when expected_md5 matches.
name is the FASTA record name. expected_md5 must be 32 hex digits.
Returns {:ok, bases} after SAM normalization. A missing or empty record
is reason: :reference_missing. A bad or different checksum is
reason: :reference_checksum_mismatch. A sequence above
:max_sequence_bytes is reason: :allocation_limit. The error does not
contain the bases.
iex> {:ok, local} = CRAM.Reference.Local.new("tutorials/fixtures/sq0.fa")
iex> CRAM.Reference.Local.fetch(local, "sq0", "be19336b7e15968f7ac7dc82493d9cd8")
{:ok, "TTCACCCA"}
iex> {:error, error} = CRAM.Reference.Local.fetch(local, "absent", "be19336b7e15968f7ac7dc82493d9cd8")
iex> error.reason
:reference_missing
@spec new(Path.t(), keyword()) :: {:ok, t()} | {:error, CRAM.Error.t()}
Read references from path.
opts may include :max_sequence_bytes, a positive integer. The default
is 64 MiB. Returns {:ok, provider} when path is a regular file.
A missing file is reason: :reference_missing. A non-positive cap is
reason: :invalid_range. Does not raise.
iex> {:ok, local} = CRAM.Reference.Local.new("tutorials/fixtures/sq0.fa", max_sequence_bytes: 1024)
iex> local.max_sequence_bytes
1024
iex> {:error, error} = CRAM.Reference.Local.new("test/fixtures/missing.fa")
iex> error.reason
:reference_missing