CRAM.Container (cram v0.1.0)

Copy Markdown View Source

A parsed CRAM container header and its block boundaries (CRAMv3 §7).

alignment_start is the integer stored in the container header. The specification does not say in this table whether that integer is 0-based or 1-based. It is not a SAM position. The EOF container uses the sentinel 4542278.

Summary

Types

t()

One container.

A permissive-mode note. The map has :reason and may include :offset, :method, :expected, and :actual.

Types

t()

@type t() :: %CRAM.Container{
  alignment_span: integer(),
  alignment_start: integer(),
  bases: non_neg_integer(),
  block_count: non_neg_integer(),
  blocks: [CRAM.Block.t()],
  crc32: non_neg_integer(),
  crc32_ok: boolean(),
  eof: boolean(),
  landmarks: [non_neg_integer()],
  length: non_neg_integer(),
  offset: non_neg_integer(),
  padding: non_neg_integer(),
  record_count: non_neg_integer(),
  record_counter: non_neg_integer(),
  reference_sequence_id: integer(),
  warnings: [warning()]
}

One container.

  • :offset — byte offset of the container header

  • :length — container body length

  • :reference_sequence_id — stored reference id. -1 is the EOF sentinel

  • :alignment_start — the stored integer, not a confirmed SAM position

  • :alignment_span — stored span

  • :record_count — records declared in the container

  • :record_counter — record counter from the header

  • :bases — base count from the header

  • :block_count — number of blocks

  • :landmarks — landmark offsets

  • :crc32 — stored CRC32 of the header bytes before the CRC field

  • :crc32_ok — whether that CRC matches

  • :blocks — parsed blocks

  • :padding — unused bytes after the blocks

  • :eof — true for the EOF sentinel container

  • :warnings — notes recorded in :permissive mode

    iex> %CRAM.Container{reference_sequence_id: -1, alignment_start: 4_542_278, record_count: 0, eof: true}.eof true

warning()

@type warning() :: map()

A permissive-mode note. The map has :reason and may include :offset, :method, :expected, and :actual.

Functions

eof?(reference_sequence_id, alignment_start, record_count)

@spec eof?(integer(), integer(), integer()) :: boolean()

True for the EOF container sentinel.

reference_sequence_id must be -1, alignment_start must be 4542278, and record_count must be 0. Any other combination is false. Does not raise.

iex> CRAM.Container.eof?(-1, 4_542_278, 0)
true
iex> CRAM.Container.eof?(0, 1, 1)
false