Package imp
Class ImputedRecBuilder
- java.lang.Object
-
- imp.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 theaddSampleData()
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 newImputedRecBuilder
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 specifiedPrintWriter
.
-
-
-
Constructor Detail
-
ImputedRecBuilder
public ImputedRecBuilder(Marker marker, int nInputTargHaps, boolean ap, boolean gp)
Constructs a newImputedRecBuilder
instance for the specified number of samples.- Parameters:
marker
- the marker corresponding to the VCF recordnInputTargHaps
- the number of input target haplotypes for haploid and diploid samplesap
-true
if posterior allele probabilities are to be printedgp
-true
if posterior genotype probabilities are to be printed- Throws:
java.lang.IllegalArgumentException
- ifnInputTargHaps < 1
java.lang.NullPointerException
- ifmarker == 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 allelea2
- the allele probabilities for the second allele- Throws:
java.lang.IndexOutOfBoundsException
- ifa1.length < this.marker().nAlleles()
java.lang.IndexOutOfBoundsException
- ifa2.length < this.marker().nAlleles()
java.lang.NullPointerException
- ifa1 == 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
- ifa1.length < this.marker().nAlleles()
java.lang.IndexOutOfBoundsException
- ifa2.length < this.marker().nAlleles()
java.lang.NullPointerException
- ifa1 == null || a2 == null
-
printRec
public void printRec(java.io.PrintWriter out, boolean isImputed)
Prints the VCF record to the specifiedPrintWriter
. 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 andfalse
otherwiseout
- thePrintWriter
to which the VCF record will be printed- Throws:
java.lang.IllegalStateException
- ifthis.hapCnt() != this.nInputTargHaps()
java.lang.NullPointerException
- ifout == null
-
-