VCF.Genotype (VCF v1.0.0)

View Source

A typed VCF genotype with arbitrary ploidy and per-allele phasing.

Each phasing entry is the optional separator prefix for the allele at the same position. This losslessly represents ordinary and VCF 4.4 partial phasing.

iex> {:ok, genotype} = VCF.Genotype.parse("0|1/2")
iex> genotype.alleles
[0, 1, 2]
iex> genotype.phasing
[nil, :phased, :unphased]
iex> VCF.Genotype.encode(genotype)
{:ok, "0|1/2"}

Summary

Functions

Encodes a genotype to canonical GT text.

Parses a GT value, including VCF 4.4 partial-phasing prefix notation.

Types

allele()

@type allele() :: non_neg_integer() | nil

phase()

@type phase() :: :phased | :unphased | nil

t()

@type t() :: %VCF.Genotype{alleles: [allele()], phasing: [phase()]}

Functions

encode(genotype)

@spec encode(t()) :: {:ok, String.t()} | {:error, VCF.Error.t()}

Encodes a genotype to canonical GT text.

parse(value)

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

Parses a GT value, including VCF 4.4 partial-phasing prefix notation.