Package vcf
Class VcfRecBuilder
java.lang.Object
vcf.VcfRecBuilder
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default initial size for the string buffer, which is 50 characters. -
Constructor Summary
ConstructorsConstructorDescriptionVcfRecBuilder
(Marker marker, int nSamples) Constructs a newVcfRecBuilder
instance with an initial capacity for the specified number of samples. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSampleData
(int allele) Adds the specified haploid phased genotype to the VCF record for the current marker.void
addSampleData
(int a1, int a2) Adds the specified diploid phased genotype to the VCF record for the current marker.marker()
Returns the current marker.void
writeRec
(PrintWriter out) Prints the current VCF record for the current marker to the specifiedPrintWriter
.
-
Field Details
-
DEFAULT_INIT_SIZE
public static final int DEFAULT_INIT_SIZEThe default initial size for the string buffer, which is 50 characters.- See Also:
-
-
Constructor Details
-
VcfRecBuilder
Constructs a newVcfRecBuilder
instance with an initial capacity for the specified number of samples.- Parameters:
marker
- the markernSamples
- the number of samples- Throws:
IllegalArgumentException
- ifnSamples < 0
-
-
Method Details
-
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 specified diploid phased genotype to the VCF record for the current marker.- Parameters:
a1
- the first allelea2
- the second allele- Throws:
IllegalStateException
- ifthis.marker() == null
IndexOutOfBoundsException
- ifa1 < 0 || a1 >= this.marker().nAlleles()
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:
IllegalStateException
- ifthis.marker() == null
IndexOutOfBoundsException
- ifallele < 0 || allele >= this.marker().nAlleles()
-
writeRec
Prints the current VCF record for the current marker to the specifiedPrintWriter
.- Parameters:
out
- thePrintWriter
to which the VCF record will be printed- Throws:
NullPointerException
- ifout == null
-