CRAM.Alignment (cram v0.1.0)

Copy Markdown View Source

One alignment in SAM field order.

pos and pnext are 1-based when present. A missing position is nil, which SAM text prints as 0. A missing sequence or quality is nil, which SAM text prints as *. Bases are not invented for a missing sequence.

tags keeps auxiliary fields. Integer, float, and string values are decoded. A character is {:char, byte}. Hex (H) is {:hex, decoded_bytes} when the text is valid hex, and {:raw, bytes} when it is not. An array is {:array, subtype, values}.

Summary

Types

t()

One SAM-shaped record.

One decoded auxiliary value.

Types

t()

@type t() :: %CRAM.Alignment{
  cigar: binary(),
  flag: non_neg_integer(),
  mapq: non_neg_integer() | nil,
  pnext: pos_integer() | nil,
  pos: pos_integer() | nil,
  qname: binary() | nil,
  qual: binary() | nil,
  rname: binary(),
  rnext: binary(),
  seq: binary() | nil,
  tags: [{binary(), tag_value()}],
  tlen: integer()
}

One SAM-shaped record.

  • :qname — query name, or nil when the writer omitted it

  • :flag — SAM flag bits

  • :rname — reference name, or "*" when unmapped

  • :pos — 1-based position, or nil when SAM would print 0

  • :mapq — mapping quality, or nil when it was not stored

  • :cigar — CIGAR string, or "*"

  • :rnext — next reference name, or "*"

  • :pnext — 1-based next position, or nil

  • :tlen — template length

  • :seq — bases, or nil when SAM would print *

  • :qual — quality bytes, or nil when SAM would print *

  • :tags — {name, value} pairs. Names stay strings

    iex> record = %CRAM.Alignment{qname: "read1", flag: 0, rname: "sq0", pos: 1, mapq: 60, cigar: "8M", rnext: "*", pnext: nil, tlen: 0, seq: "TTCACCCA", qual: "IIIIIIII", tags: [{"RG", "g1"}]} iex> {record.pos, record.tags} {1, [{"RG", "g1"}]}

tag_value()

@type tag_value() ::
  integer()
  | float()
  | binary()
  | {:char, binary()}
  | {:hex, binary()}
  | {:raw, binary()}
  | {:array, binary(), [integer() | float()]}

One decoded auxiliary value.

An integer, float, or string is the value itself. {:char, byte} is SAM type A. {:hex, bytes} is type H after hex decoding. {:raw, bytes} is type H whose text was not hex. {:array, subtype, values} is type B.