SAM header text stored in a CRAM file, plus the fields this library reads.
Unknown header lines are kept as binaries in other. Tag names from the file
stay strings. They are never turned into atoms.
Summary
Functions
Parse SAM header text.
Types
@type t() :: %CRAM.Header{ comments: [String.t()], other: [binary()], programs: [map()], raw: binary(), read_groups: [map()], sequences: [CRAM.Header.Sequence.t()], sort_order: String.t() | nil, version: String.t() | nil }
A parsed SAM header.
:raw— the header text that was parsed:version—@HD VN, ornil:sort_order—@HD SO, ornil:sequences—@SQlines, in file order:read_groups—@RGlines as string-keyed maps:programs—@PGlines as string-keyed maps:comments—@COtext, without the type tag:other— lines this parser does not classifyiex> {:ok, header} = CRAM.Header.parse("@HD\tVN:1.6\n") iex> header.version "1.6"
Functions
@spec parse(binary()) :: {:ok, t()} | {:error, CRAM.Error.t()}
Parse SAM header text.
Returns {:ok, header}. An @SQ line without LN is
reason: :bad_header. An LN that is not a non-negative integer is the
same reason. Tag names stay strings. Does not raise.
iex> text = "@HD\tVN:1.6\tSO:unsorted\n@SQ\tSN:sq0\tLN:8\tM5:be19336b7e15968f7ac7dc82493d9cd8\n"
iex> {:ok, header} = CRAM.Header.parse(text)
iex> hd(header.sequences).name
"sq0"
iex> {:error, missing} = CRAM.Header.parse("@SQ\tSN:sq0\n")
iex> missing.detail
"@SQ line is missing LN"
iex> {:error, bad} = CRAM.Header.parse("@SQ\tSN:sq0\tLN:x\n")
iex> bad.detail
"@SQ LN is not a non-negative integer"