Package vcf
Class VcfWriter
java.lang.Object
vcf.VcfWriter
Class VcfWriter
contains static methods for writing data in
VCF 4.2 format.
Instances of class VcfWriter
are not thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendRecords
(GT phasedTarg, int start, int end, PrintWriter out) Writes the data in phased genotypes for the specified markers to the specifiedPrintWriter
.static void
appendRecords
(Samples samples, GTRec[] recs, PrintWriter out) Writes the data in phased genotypes for the specified markers to the specifiedPrintWriter
.static void
printFixedFieldsGT
(Marker marker, PrintWriter out) Prints the first 9 VCF record fields for the specified marker to the specifiedPrintWriter
.static void
writeMetaLines
(String[] sampleIds, String source, boolean ds, boolean ap, boolean gp, boolean gl, PrintWriter out) Writes VCF meta-information lines and header line to the specifiedPrintWriter
.static void
writeMetaLinesGT
(String[] sampleIds, String source, PrintWriter out) Writes VCF meta-information lines and header line to the specifiedPrintWriter
.
-
Method Details
-
writeMetaLinesGT
Writes VCF meta-information lines and header line to the specifiedPrintWriter
. Only one FORMAT subfield, the GT subfield, is described in the meta-information lines.- Parameters:
sampleIds
- the sample identifierssource
- a description of the data source, ornull
if no description is to be printedout
- thePrintWriter
to which VCF meta-information lines will be written- Throws:
NullPointerException
- ifout == null
NullPointerException
- ifsampleIds == null
, or ifsampleIds[j] == null
for anyj
satisfying(0 <= j && j < <sampleIds.length)
-
writeMetaLines
public static void writeMetaLines(String[] sampleIds, String source, boolean ds, boolean ap, boolean gp, boolean gl, PrintWriter out) Writes VCF meta-information lines and header line to the specifiedPrintWriter
.- Parameters:
sampleIds
- the sample identifierssource
- a description of the data source, ornull
if no description is to be printedds
- { @code true} if the meta-information lines will describe the DS FORMAT subfield andfalse
otherwiseap
-true
if the meta-information lines will describe the AP1 and AP2 FORMAT subfields andfalse
otherwisegp
-true
if the meta-information lines will describe the GP FORMAT subfield andfalse
otherwisegl
-true
if the meta-information lines will describe the GL FORMAT subfield andfalse
otherwiseout
- thePrintWriter
to which VCF meta-information lines will be written.- Throws:
NullPointerException
- ifout == null
NullPointerException
- ifsampleIds == null
, or ifsampleIds[j] == null
for anyj
satisfying(0 <= j && j < sampleIds.length)
-
appendRecords
Writes the data in phased genotypes for the specified markers to the specifiedPrintWriter
.- Parameters:
phasedTarg
- the estimated haplotype allele probabilitiesstart
- the starting marker index (inclusive)end
- the ending marker index (exclusive)out
- thePrintWriter
to which VCF records will be written- Throws:
IllegalArgumentException
- ifphasedTarg.isPhased() == false
IndexOutOfBoundsException
- if(start < 0 || start > end || end > phasedTarg.nMarkers())
NullPointerException
- ifphasedTarg == null || out == null
-
appendRecords
Writes the data in phased genotypes for the specified markers to the specifiedPrintWriter
.- Parameters:
samples
- the list of samplesrecs
- the estimated haplotype allele probabilitiesout
- thePrintWriter
to which VCF records will be written- Throws:
IllegalArgumentException
- ifphasedTarg.isPhased() == false
IndexOutOfBoundsException
- if(start < 0 || start > end || end > phasedTarg.nMarkers())
NullPointerException
- ifphasedTarg == null || out == null
-
printFixedFieldsGT
Prints the first 9 VCF record fields for the specified marker to the specifiedPrintWriter
. Only one VCF FORMAT subfield, the GT subfield, is printed.- Parameters:
marker
- a markerout
- thePrintWriter
to which the first 9 VCF record fields will be written- Throws:
NullPointerException
- ifmarker == null || out == null
-