Package vcf
Class VcfRecBuilder
- java.lang.Object
-
- vcf.VcfRecBuilder
-
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 theaddSampleData()
method.Instances of class
VcfRecBuilder
are not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_INIT_SIZE
The default initial size for the string buffer, which is 50 characters.
-
Constructor Summary
Constructors Constructor Description VcfRecBuilder(Marker marker, int nSamples)
Constructs a newVcfRecBuilder
instance with an initial capacity for the specified number of samples.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSampleData(int a1, int a2)
Adds the FORMAT field for a sample to the VCF record for the current marker.Marker
marker()
Returns the current marker.void
writeRec(java.io.PrintWriter out)
Prints the current VCF record for the current marker to the specifiedPrintWriter
.
-
-
-
Field Detail
-
DEFAULT_INIT_SIZE
public static final int DEFAULT_INIT_SIZE
The default initial size for the string buffer, which is 50 characters.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VcfRecBuilder
public VcfRecBuilder(Marker marker, int nSamples)
Constructs a newVcfRecBuilder
instance with an initial capacity for the specified number of samples.- Parameters:
marker
- the markernSamples
- the number of samples- Throws:
java.lang.IllegalArgumentException
- ifnSamples < 0
-
-
Method Detail
-
marker
public Marker marker()
Returns the current marker. Returnsnull
ifthis.reset()
has not been previously invoked.- Returns:
- the current marker.
-
addSampleData
public void addSampleData(int a1, int a2)
Adds the FORMAT field for a sample to the VCF record for the current marker.- Parameters:
a1
- the first allelea2
- the second allele- Throws:
java.lang.IllegalStateException
- ifthis.marker() == null
java.lang.IndexOutOfBoundsException
- ifa1 < 0 || a1 >= this.marker().nAlleles()
java.lang.IndexOutOfBoundsException
- ifa2 < 0 || a2 >= this.marker().nAlleles()
-
writeRec
public void writeRec(java.io.PrintWriter out)
Prints the current VCF record for the current marker to the specifiedPrintWriter
.- Parameters:
out
- thePrintWriter
to which the VCF record will be printed- Throws:
java.lang.NullPointerException
- ifout == null
-
-