Package imp

Class ImputedRecBuilder

java.lang.Object
imp.ImputedRecBuilder

public final class ImputedRecBuilder extends Object

Class ImputeRecBuilder contains methods for constructing and printing a VCF record in VCF 4.3 format. The sample data in the output VCF record are in the same order that the data were added with the addSampleData() method.

Instances of class ImputeRecBuilder are not thread-safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ImputedRecBuilder(Marker marker, int nInputTargHaps, boolean ap, boolean gp)
    Constructs a new ImputedRecBuilder instance for the specified number of samples.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addSampleData(float[] a1)
    Scales the specified probabilities for each allele to each sum to 1.0, and adds the sample data to the VCF record.
    void
    addSampleData(float[] a1, float[] a2)
    Scales the specified probabilities for each allele to each sum to 1.0, and adds the sample data to the VCF record.
    int
    Returns the number of imputed alleles added by the addSampleData() methods.
    Returns the marker in the VCF record.
    int
    Returns the number of input target haplotypes for haploid and diploid samples.
    void
    printRec(PrintWriter out, boolean isImputed)
    Prints the VCF record to the specified PrintWriter.

    Methods inherited from class java.lang.Object

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

    • ImputedRecBuilder

      public ImputedRecBuilder(Marker marker, int nInputTargHaps, boolean ap, boolean gp)
      Constructs a new ImputedRecBuilder instance for the specified number of samples.
      Parameters:
      marker - the marker corresponding to the VCF record
      nInputTargHaps - the number of input target haplotypes for haploid and diploid samples
      ap - true if posterior allele probabilities are to be printed
      gp - true if posterior genotype probabilities are to be printed
      Throws:
      IllegalArgumentException - if nInputTargHaps < 1
      NullPointerException - if marker == null
  • Method Details

    • marker

      public Marker marker()
      Returns the marker in the VCF record.
      Returns:
      the marker in the VCF record
    • nInputTargHaps

      public int nInputTargHaps()
      Returns the number of input target haplotypes for haploid and diploid samples.
      Returns:
      the number of input target haplotypes for haploid and diploid samples
    • hapCnt

      public int hapCnt()
      Returns the number of imputed alleles added by the addSampleData() methods.
      Returns:
      the number of imputed alleles added by the addSampleData() methods
    • addSampleData

      public void addSampleData(float[] a1, float[] a2)
      Scales the specified probabilities for each allele to each sum to 1.0, and adds the sample data to the VCF record. The contract for this method is undefined if any element of the specified arrays is not a finite non-negative number.
      Parameters:
      a1 - the allele probabilities for the first allele
      a2 - the allele probabilities for the second allele
      Throws:
      IndexOutOfBoundsException - if a1.length < this.marker().nAlleles()
      IndexOutOfBoundsException - if a2.length < this.marker().nAlleles()
      NullPointerException - if a1 == null || a2 == null
    • addSampleData

      public void addSampleData(float[] a1)
      Scales the specified probabilities for each allele to each sum to 1.0, and adds the sample data to the VCF record. The contract for this method is undefined if any element of the specified arrays is not a finite non-negative number.
      Parameters:
      a1 - the allele probabilities
      Throws:
      IndexOutOfBoundsException - if a1.length < this.marker().nAlleles()
      IndexOutOfBoundsException - if a2.length < this.marker().nAlleles()
      NullPointerException - if a1 == null || a2 == null
    • printRec

      public void printRec(PrintWriter out, boolean isImputed)
      Prints the VCF record to the specified PrintWriter. The INFO field of the VCF record will include the DR2 (dose r2) and AF (ALT allele frequency) subfields.
      Parameters:
      out - the PrintWriter to which the VCF record will be printed
      isImputed - true if the INFO field of the VCF record will have an IMP flag and false otherwise
      Throws:
      IllegalStateException - if this.hapCnt() != this.nInputTargHaps()
      NullPointerException - if out == null