cljam.io.vcf

Functions to read and write the VCF (Variant Call Format) format and BCF (its
binary equivalent). See https://samtools.github.io/hts-specs/ for the detail
VCF/BCF specifications.

bcf-reader

(bcf-reader f)
Returns an open cljam.io.bcf.reader.BCFReader of f. Should be used inside
with-open to ensure the reader is properly closed. Throws IOException if
failed to parse BCF file format.

bcf-writer

(bcf-writer f meta-info header)
Returns an open cljam.io.bcf.writer.BCFWriter of f. Meta-information lines
and a header line will be written in this function. Should be used inside
with-open to ensure the writer is properly closed. e.g.

   (with-open [wtr (bcf-writer "out.bcf"
                               {:file-date "20090805", :source "myImpu..." ...}
                               ["CHROM" "POS" "ID" "REF" "ALT" ...])]
     (WRITING-BCF))

clone-bcf-reader

(clone-bcf-reader rdr)
Clones bcf reader sharing persistent objects.

clone-reader

(clone-reader rdr)
Clones vcf/bcf reader sharing persistent objects.

clone-vcf-reader

(clone-vcf-reader rdr)
Clones vcf reader sharing persistent objects.

header

(header rdr)
Returns header of VCF/BCF file as a sequence of strings.

indexed?

(indexed? rdr)
Returns true if the reader can be randomly accessed, false if not. Note this
function immediately realizes a delayed index.

meta-info

(meta-info rdr)
Returns meta-info section of VCF/BCF file as a map.

read-file-offsets

(read-file-offsets rdr)
Reads offsets {:file-beg :file-end :beg :end :chr } from VCF/BCF file.

read-variants

(read-variants rdr)(read-variants rdr option)
Reads variants of the VCF/BCF file, returning them as a lazy sequence. rdr
must implement cljam.io.protocols/IVariantReader. Can take an option :depth to
specify parsing level, default :deep. <:deep|:vcf|:bcf|:shallow|:raw>
  :deep - Fully parsed variant map. FORMAT, FILTER, INFO and samples columns are parsed.
  :vcf - VCF-style map. FORMAT, FILTER, INFO and samples columns are strings.
  :bcf - BCF-style map. CHROM, FILTER, INFO and :genotype contains indices to meta-info.
  :shallow - Only CHROM, POS and ref-length are parsed.
  :raw - Raw map of ByteBufers.

read-variants-randomly

(read-variants-randomly rdr span-option depth-option)
Reads variants of the VCF/BCF file randomly, returning them as a lazy sequence.

reader

(reader f)
Selects suitable reader from f's extension, returning the open reader. This
function supports VCF and BCF formats.

vcf-reader

(vcf-reader f)
Returns an open cljam.io.vcf.reader.VCFReader of f. Should be used inside
with-open to ensure the reader is properly closed.

vcf-writer

(vcf-writer f meta-info header)
Returns an open cljam.io.vcf.writer.VCFWriter of f. Meta-information lines
and a header line will be written in this function. Should be used inside
with-open to ensure the writer is properly closed. e.g.

  (with-open [wtr (vcf-writer "out.vcf"
                              {:file-date "20090805", :source "myImpu..." ...}
                              ["CHROM" "POS" "ID" "REF" "ALT" ...])]
    (WRITING-VCF))

write-variants

(write-variants wtr variants)
Writes variants to the VCF/BCF file. wtr must implement
cljam.io.protocols/IVariantWriter. variants must be a sequence of parsed or
VCF-style maps. e.g.

  (write-variants [{:chr "19", :pos 111, :id nil, :ref "A",
                    :alt ["C"], :qual 9.6, :filter [:PASS], :info {:DP 4},
                    :FORMAT [:GT :HQ] ...} ...])

writer

(writer f meta-info header)
Selects suitable writer from f's extension, returning the open writer. This
function supports VCF and BCF formats.