public class VCFEncoder
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.nio.charset.Charset |
VCF_CHARSET
The encoding used for VCF files: ISO-8859-1.
|
| Constructor and Description |
|---|
VCFEncoder(VCFHeader header,
boolean allowMissingFieldsInHeader,
boolean outputTrailingFormatFields)
Prepare a VCFEncoder that will encode records appropriate to the given VCF header, optionally
allowing missing fields in the header.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addGenotypeData(VariantContext vc,
java.util.Map<Allele,java.lang.String> alleleMap,
java.util.List<java.lang.String> genotypeFormatKeys,
java.lang.StringBuilder builder) |
static java.util.Map<Allele,java.lang.String> |
buildAlleleStrings(VariantContext vc)
return a Map containing Allele -> String(allele position) for all Alleles in VC
(as well as NO_CALL)
ex: A,T,TC -> { A:0, T:1, TC:2, NO_CALL:EMPTY_ALLELE}
This may be efficient when looking up values for many genotypes per VC
|
java.lang.String |
encode(VariantContext context)
encodes a
VariantContext as a VCF line
Depending on the use case it may be more efficient to write(Appendable, VariantContext) directly
instead of creating an intermediate string. |
static java.lang.String |
encodeGtField(VariantContext vc,
Genotype g)
Easy way to generate the GT field for a Genotype.
|
static java.lang.String |
formatVCFDouble(double d)
Takes a double value and pretty prints it to a String for display
|
void |
setAllowMissingFieldsInHeader(boolean allow)
Deprecated.
since 10/24/13 use the constructor
|
void |
setVCFHeader(VCFHeader header)
Deprecated.
since 10/24/13 use the constructor
|
void |
write(java.lang.Appendable vcfOutput,
VariantContext context)
encodes a
VariantContext context as VCF, and writes it directly to an Appendable
This may be more efficient than calling encode(VariantContext) and then writing the result since it
avoids creating an intermediate string. |
static void |
writeGtField(java.util.Map<Allele,java.lang.String> alleleMap,
java.lang.Appendable vcfoutput,
Genotype g)
write the encoded GT field for a Genotype
|
public static final java.nio.charset.Charset VCF_CHARSET
public VCFEncoder(VCFHeader header, boolean allowMissingFieldsInHeader, boolean outputTrailingFormatFields)
@Deprecated public void setVCFHeader(VCFHeader header)
@Deprecated public void setAllowMissingFieldsInHeader(boolean allow)
public java.lang.String encode(VariantContext context)
VariantContext as a VCF line
Depending on the use case it may be more efficient to write(Appendable, VariantContext) directly
instead of creating an intermediate string.public void write(java.lang.Appendable vcfOutput,
VariantContext context)
throws java.io.IOException
VariantContext context as VCF, and writes it directly to an Appendable
This may be more efficient than calling encode(VariantContext) and then writing the result since it
avoids creating an intermediate string.vcfOutput - the Appendable to write tocontext - the variantjava.io.IOExceptionpublic static java.lang.String formatVCFDouble(double d)
Large doubles => gets %.2f style formatting Doubles < 1 / 10 but > 1/100 => get %.3f style formatting Double < 1/100 => %.3e formatting
d - public void addGenotypeData(VariantContext vc, java.util.Map<Allele,java.lang.String> alleleMap, java.util.List<java.lang.String> genotypeFormatKeys, java.lang.StringBuilder builder)
public static void writeGtField(java.util.Map<Allele,java.lang.String> alleleMap, java.lang.Appendable vcfoutput, Genotype g) throws java.io.IOException
alleleMap - a mapping of Allele -> GT allele value (from this#buildAlleleStrings(VariantContext)vcfoutput - the appendable to write to, to avoid inefficiency due to string copyingg - the genotoype to encodejava.io.IOException - if appending fails with an IOExceptionpublic static java.lang.String encodeGtField(VariantContext vc, Genotype g)
this#writeGtField(Map, Appendable, Genotype) because of redundant Map initializationsvc - a VariantContext which must contain g or the results are likely to be incorrectg - a Genotype in vcpublic static java.util.Map<Allele,java.lang.String> buildAlleleStrings(VariantContext vc)