Package vcf

Class VcfRecBuilder

java.lang.Object
vcf.VcfRecBuilder

public final class VcfRecBuilder extends Object

Class VcfRecBuilder contains methods for constructing and printing a VCF record in VCF 4.2 format. The FORMAT field data for each sample is added sequentially to the record via the addSampleData() method.

Instances of class VcfRecBuilder are not thread-safe.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default initial size for the string buffer, which is 50 characters.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VcfRecBuilder(Marker marker, int nSamples)
    Constructs a new VcfRecBuilder instance with an initial capacity for the specified number of samples.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addSampleData(int allele)
    Adds the specified haploid phased genotype to the VCF record for the current marker.
    void
    addSampleData(int a1, int a2)
    Adds the specified diploid phased genotype to the VCF record for the current marker.
    Returns the current marker.
    void
    Prints the current VCF record for the current marker to the specified PrintWriter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_INIT_SIZE

      public static final int DEFAULT_INIT_SIZE
      The default initial size for the string buffer, which is 50 characters.
      See Also:
  • Constructor Details

    • VcfRecBuilder

      public VcfRecBuilder(Marker marker, int nSamples)
      Constructs a new VcfRecBuilder instance with an initial capacity for the specified number of samples.
      Parameters:
      marker - the marker
      nSamples - the number of samples
      Throws:
      IllegalArgumentException - if nSamples < 0
  • Method Details

    • marker

      public Marker marker()
      Returns the current marker. Returns null if this.reset() has not been previously invoked.
      Returns:
      the current marker.
    • addSampleData

      public void addSampleData(int a1, int a2)
      Adds the specified diploid phased genotype to the VCF record for the current marker.
      Parameters:
      a1 - the first allele
      a2 - the second allele
      Throws:
      IllegalStateException - if this.marker() == null
      IndexOutOfBoundsException - if a1 < 0 || a1 >= this.marker().nAlleles()
      IndexOutOfBoundsException - if a2 < 0 || a2 >= this.marker().nAlleles()
    • addSampleData

      public void addSampleData(int allele)
      Adds the specified haploid phased genotype to the VCF record for the current marker.
      Parameters:
      allele - the allele
      Throws:
      IllegalStateException - if this.marker() == null
      IndexOutOfBoundsException - if allele < 0 || allele >= this.marker().nAlleles()
    • writeRec

      public void writeRec(PrintWriter out)
      Prints the current VCF record for the current marker to the specified PrintWriter.
      Parameters:
      out - the PrintWriter to which the VCF record will be printed
      Throws:
      NullPointerException - if out == null