Package vcf
Class VcfRecBuilder
- java.lang.Object
-
- vcf.VcfRecBuilder
-
public final class VcfRecBuilder extends java.lang.ObjectClass
VcfRecBuildercontains 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
VcfRecBuilderare not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_INIT_SIZEThe default initial size for the string buffer, which is 50 characters.
-
Constructor Summary
Constructors Constructor Description VcfRecBuilder(Marker marker, int nSamples)Constructs a newVcfRecBuilderinstance with an initial capacity for the specified number of samples.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSampleData(int allele)Adds the specified haploid phased genotype to the VCF record for the current marker.voidaddSampleData(int a1, int a2)Adds the specified diploid phased genotype to the VCF record for the current marker.Markermarker()Returns the current marker.voidwriteRec(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 newVcfRecBuilderinstance 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. Returnsnullifthis.reset()has not been previously invoked.- Returns:
- the current marker.
-
addSampleData
public void addSampleData(int a1, int a2)Adds the specified diploid phased genotype to the VCF record for the current marker.- Parameters:
a1- the first allelea2- the second allele- Throws:
java.lang.IllegalStateException- ifthis.marker() == nulljava.lang.IndexOutOfBoundsException- ifa1 < 0 || a1 >= this.marker().nAlleles()java.lang.IndexOutOfBoundsException- ifa2 < 0 || a2 >= this.marker().nAlleles()
-
addSampleData
public void addSampleData(int allele)
Adds the specified haploid phased genotype to the VCF record for the current marker.- Parameters:
allele- the allele- Throws:
java.lang.IllegalStateException- ifthis.marker() == nulljava.lang.IndexOutOfBoundsException- ifallele < 0 || allele >= 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- thePrintWriterto which the VCF record will be printed- Throws:
java.lang.NullPointerException- ifout == null
-
-