Package imp

Class ImputedRecBuilder


  • public final class ImputedRecBuilder
    extends java.lang.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

      All Methods Instance Methods Concrete Methods 
      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 hapCnt()
      Returns the number of imputed alleles added by the addSampleData() methods.
      Marker marker()
      Returns the marker in the VCF record.
      int nInputTargHaps()
      Returns the number of input target haplotypes for haploid and diploid samples.
      void printRec​(java.io.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 Detail

      • 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:
        java.lang.IllegalArgumentException - if nInputTargHaps < 1
        java.lang.NullPointerException - if marker == null
    • Method Detail

      • 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:
        java.lang.IndexOutOfBoundsException - if a1.length < this.marker().nAlleles()
        java.lang.IndexOutOfBoundsException - if a2.length < this.marker().nAlleles()
        java.lang.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:
        java.lang.IndexOutOfBoundsException - if a1.length < this.marker().nAlleles()
        java.lang.IndexOutOfBoundsException - if a2.length < this.marker().nAlleles()
        java.lang.NullPointerException - if a1 == null || a2 == null
      • printRec

        public void printRec​(java.io.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:
        isImputed - true if the INFO field of the VCF record will have an IMP flag and false otherwise
        out - the PrintWriter to which the VCF record will be printed
        Throws:
        java.lang.IllegalStateException - if this.hapCnt() != this.nInputTargHaps()
        java.lang.NullPointerException - if out == null