VCF (VCF v1.0.0)

View Source

Parse, validate, stream, transform, and write Variant Call Format files.

parse/2 always treats its binary argument as VCF content. Use read/2 or stream/2 for paths, caller-owned I/O devices, and binary enumerables.

Quick start

iex> lines = ["##fileformat=VCFv4.5", "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO", "chr1\t10\t.\tA\tC\t.\tPASS\t."]
iex> source = Enum.join(lines, <<10>>) <> <<10>>
iex> {:ok, document} = VCF.parse(source)
iex> [record] = document.records
iex> {record.chrom, record.pos, record.filter}
{"chr1", 10, :pass}

Complete-input functions have bang variants that raise VCF.ParseError. Lazy bang streams yield records directly; non-bang streams yield tagged results.

Summary

Functions

Encodes a document, stream, or header plus records to canonical VCF text.

Encodes canonical VCF text or raises VCF.ParseError.

Lazily filters records while preserving stream header context.

Parses an in-memory VCF binary into a document.

Parses an in-memory VCF binary or raises VCF.ParseError.

Reads a path, I/O device, or binary enumerable into a document.

Reads a complete source or raises VCF.ParseError.

Opens a non-bang lazy stream whose elements are tagged results.

Opens a lazy record stream that raises on the first error.

Returns the supported VCF specification versions.

Validates every record in a fully collected document.

Writes a document or stream to a path or I/O device.

Writes a document or stream or raises VCF.ParseError.

Functions

encode(data, options \\ [])

@spec encode(VCF.Header.t(), Enumerable.t()) ::
  {:ok, binary()} | {:error, VCF.Error.t() | [VCF.Error.t()]}
@spec encode(
  VCF.Document.t() | VCF.Stream.t(),
  keyword()
) :: {:ok, binary()} | {:error, VCF.Error.t() | [VCF.Error.t()]}

Encodes a document, stream, or header plus records to canonical VCF text.

encode(header, records, options)

@spec encode(VCF.Header.t(), Enumerable.t(), keyword()) ::
  {:ok, binary()} | {:error, VCF.Error.t() | [VCF.Error.t()]}

encode!(data, options \\ [])

@spec encode!(VCF.Header.t(), Enumerable.t()) :: binary()
@spec encode!(
  VCF.Document.t() | VCF.Stream.t(),
  keyword()
) :: binary()

Encodes canonical VCF text or raises VCF.ParseError.

encode!(header, records, options)

@spec encode!(VCF.Header.t(), Enumerable.t(), keyword()) :: binary()

filter(stream, predicate)

@spec filter(VCF.Stream.t(), (VCF.Record.t() -> as_boolean(term()))) :: VCF.Stream.t()

Lazily filters records while preserving stream header context.

parse(content, options \\ [])

@spec parse(
  binary(),
  keyword()
) :: {:ok, VCF.Document.t()} | {:error, VCF.Error.t()}

Parses an in-memory VCF binary into a document.

parse!(content, options \\ [])

@spec parse!(
  binary(),
  keyword()
) :: VCF.Document.t()

Parses an in-memory VCF binary or raises VCF.ParseError.

read(source, options \\ [])

@spec read(
  term(),
  keyword()
) :: {:ok, VCF.Document.t()} | {:error, VCF.Error.t()}

Reads a path, I/O device, or binary enumerable into a document.

read!(source, options \\ [])

@spec read!(
  term(),
  keyword()
) :: VCF.Document.t()

Reads a complete source or raises VCF.ParseError.

stream(source, options \\ [])

@spec stream(
  term(),
  keyword()
) :: {:ok, VCF.Stream.t()} | {:error, VCF.Error.t()}

Opens a non-bang lazy stream whose elements are tagged results.

stream!(source, options \\ [])

@spec stream!(
  term(),
  keyword()
) :: VCF.Stream.t()

Opens a lazy record stream that raises on the first error.

supported_versions()

@spec supported_versions() :: [String.t()]

Returns the supported VCF specification versions.

validate(document, options \\ [])

@spec validate(
  VCF.Document.t(),
  keyword()
) :: :ok | {:error, [VCF.Error.t()]}

Validates every record in a fully collected document.

write(data, destination, options \\ [])

@spec write(VCF.Document.t() | VCF.Stream.t(), term(), keyword()) ::
  :ok | {:error, VCF.Error.t() | [VCF.Error.t()]}
@spec write(term(), VCF.Document.t() | VCF.Stream.t(), keyword()) ::
  :ok | {:error, VCF.Error.t() | [VCF.Error.t()]}
@spec write(term(), VCF.Header.t(), Enumerable.t()) ::
  :ok | {:error, VCF.Error.t() | [VCF.Error.t()]}

Writes a document or stream to a path or I/O device.

write(destination, header, records, options)

@spec write(term(), VCF.Header.t(), Enumerable.t(), keyword()) ::
  :ok | {:error, VCF.Error.t() | [VCF.Error.t()]}

write!(data, destination, options \\ [])

@spec write!(VCF.Document.t() | VCF.Stream.t(), term(), keyword()) :: :ok
@spec write!(term(), VCF.Document.t() | VCF.Stream.t(), keyword()) :: :ok
@spec write!(term(), VCF.Header.t(), Enumerable.t()) :: :ok

Writes a document or stream or raises VCF.ParseError.

write!(destination, header, records, options)

@spec write!(term(), VCF.Header.t(), Enumerable.t(), keyword()) :: :ok