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 nSamples, 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, float[] a2)
Scales the specified probabilities for each allele to each sum to 1.0, and adds the sample data to the VCF record.Marker
marker()
Returns the marker in the VCF record.int
nSamples()
Returns the required number of samples in the VCF record.void
printRec(java.io.PrintWriter out, boolean isImputed)
Prints the VCF record to the specifiedPrintWriter
.int
sampleCnt()
Returns the number of times thethis.addSampleData()
method has been invoked.
-
-
-
Constructor Detail
-
ImputedRecBuilder
public ImputedRecBuilder(Marker marker, int nSamples, boolean ap, boolean gp)
Constructs a newImputedRecBuilder
instance for the specified number of samples.- Parameters:
marker
- the marker corresponding to the VCF recordnSamples
- the number of samplesap
-true
if posterior allele probabilities are to be printedgp
-true
if posterior genotype probabilities are to be printed- Throws:
java.lang.IllegalArgumentException
- ifnSamples < 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
-
nSamples
public int nSamples()
Returns the required number of samples in the VCF record.- Returns:
- the required number of samples in the VCF record
-
sampleCnt
public int sampleCnt()
Returns the number of times thethis.addSampleData()
method has been invoked.- Returns:
- the number of times the
this.addSampleData()
method has been invoked
-
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
-
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.nSamples() != this.sampleCnt()
java.lang.NullPointerException
- ifout == null
-
-