public final class VcfRecBuilder
extends java.lang.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.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INIT_SIZE
The default initial size for the string buffer, which is 50
characters.
|
| Constructor and Description |
|---|
VcfRecBuilder()
Constructs a new
VcfRecBuilder instance with initial buffer
size equal to VcfRecBuilder.DEFAULT_INIT_SIZE. |
VcfRecBuilder(int initSize)
Constructs a new
VcfRecBuilder instance with the specified
initial buffer size. |
| Modifier and Type | Method and Description |
|---|---|
void |
addSampleData(double[] gtypeProbs)
Adds the FORMAT field for a sample to the VCF record for the current
marker.
|
void |
addSampleData(double[] alProbs1,
double[] alProbs2)
Adds the FORMAT field for a sample to the VCF record for the current
marker.
|
Marker |
marker()
Returns the current marker.
|
boolean |
printDS()
Returns
true if the FORMAT field in the VCF record for
this marker includes a DS subfield, and false otherwise |
boolean |
printGP()
Returns
true if the FORMAT field in the VCF record for
this marker includes a GP subfield, and false otherwise |
void |
reset(Marker marker,
boolean printDS,
boolean printGP)
Clears existing data, and sets the current marker to the specified
marker.
|
void |
writeRec(java.io.PrintWriter out,
boolean isImputed)
Prints the current VCF record for the current marker to the specified
PrintWriter. |
public static final int DEFAULT_INIT_SIZE
public VcfRecBuilder()
VcfRecBuilder instance with initial buffer
size equal to VcfRecBuilder.DEFAULT_INIT_SIZE.public VcfRecBuilder(int initSize)
VcfRecBuilder instance with the specified
initial buffer size.initSize - the initial buffer sizejava.lang.NegativeArraySizeException - if initCapacity < 0public void reset(Marker marker, boolean printDS, boolean printGP)
marker - the marker to which data will be addedprintDS - true if the FORMAT field in the VCF record for
this marker will include a DS subfield, and false otherwiseprintGP - true if the FORMAT field in the VCF record for
this marker will include a GP subfield, and false otherwisejava.lang.NullPointerException - if marker == nullpublic Marker marker()
null if
this.reset() has not been previously invoked.public boolean printDS()
true if the FORMAT field in the VCF record for
this marker includes a DS subfield, and false otherwisetrue if the FORMAT field in the VCF record for
this marker includes a DS subfieldpublic boolean printGP()
true if the FORMAT field in the VCF record for
this marker includes a GP subfield, and false otherwisetrue if the FORMAT field in the VCF record for
this marker includes a GP subfieldpublic void addSampleData(double[] gtypeProbs)
gtypeProbs - the posterior genotype probabilitiesjava.lang.IllegalArgumentException - if
gtProbs.length != this.marker().nGenotypes()java.lang.IllegalArgumentException - if any element of the specified
array is not a finite non-negative numberjava.lang.IllegalStateException - if this.marker() == nulljava.lang.NullPointerException - if gtProbs == nullpublic void addSampleData(double[] alProbs1,
double[] alProbs2)
alProbs1 - the posterior allele probabilities for the individual's
first allelealProbs2 - the posterior allele probabilities for the individual's
second allelejava.lang.IllegalArgumentException - if
alProbs1.length != this.marker().nAlleles()java.lang.IllegalArgumentException - if
alProbs2.length != this.marker().nAlleles()java.lang.IllegalArgumentException - if any element of the specified
array is not a finite non-negative numberjava.lang.IllegalStateException - if this.marker() == nulljava.lang.NullPointerException - if
alProbs1 == null || alProbs2 == nullpublic void writeRec(java.io.PrintWriter out,
boolean isImputed)
PrintWriter. If the FORMAT field contains a DS or GP subfield,
the INFO field will include the AR2 (allele r2), DR2 (dose r2), and
AF (ALT allele frequency) subfields. Invocation of this method has
no effect if this.reset() has not previously been invoked.out - the PrintWriter to which the VCF record will be
printedisImputed - true if the printed VCF record will
have an IMP flag in the INFO field and false otherwisejava.lang.NullPointerException - if out == null