Package htsjdk.variant.vcf
Class VCFEncoder
java.lang.Object
htsjdk.variant.vcf.VCFEncoder
Functions specific to encoding VCF records.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CharsetThe encoding used for VCF files: ISO-8859-1. -
Constructor Summary
ConstructorsConstructorDescriptionVCFEncoder(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGenotypeData(VariantContext vc, Map<Allele, String> alleleMap, List<String> genotypeFormatKeys, StringBuilder builder) encode(VariantContext context) encodes aVariantContextas a VCF line Depending on the use case it may be more efficient towrite(Appendable, VariantContext)directly instead of creating an intermediate string.static StringformatVCFDouble(double d) Takes a double value and pretty prints it to a String for displayvoidsetAllowMissingFieldsInHeader(boolean allow) Deprecated.since 10/24/13 use the constructorvoidsetVCFHeader(VCFHeader header) Deprecated.since 10/24/13 use the constructorvoidwrite(Appendable vcfOutput, VariantContext context) encodes aVariantContextcontext as VCF, and writes it directly to anAppendableThis may be more efficient than callingencode(VariantContext)and then writing the result since it avoids creating an intermediate string.
-
Field Details
-
VCF_CHARSET
The encoding used for VCF files: ISO-8859-1. When writing VCF4.3 is implemented, this should change to UTF-8.
-
-
Constructor Details
-
VCFEncoder
public 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.
-
-
Method Details
-
setVCFHeader
Deprecated.since 10/24/13 use the constructor -
setAllowMissingFieldsInHeader
Deprecated.since 10/24/13 use the constructor -
encode
encodes aVariantContextas a VCF line Depending on the use case it may be more efficient towrite(Appendable, VariantContext)directly instead of creating an intermediate string.- Returns:
- the VCF line
-
write
encodes aVariantContextcontext as VCF, and writes it directly to anAppendableThis may be more efficient than callingencode(VariantContext)and then writing the result since it avoids creating an intermediate string.- Parameters:
vcfOutput- theAppendableto write tocontext- the variant- Throws:
IOException
-
formatVCFDouble
Takes a double value and pretty prints it to a String for displayLarge doubles => gets %.2f style formatting Doubles < 1 / 10 but > 1/100 => get %.3f style formatting Double < 1/100 => %.3e formatting
- Parameters:
d-- Returns:
-
addGenotypeData
public void addGenotypeData(VariantContext vc, Map<Allele, String> alleleMap, List<String> genotypeFormatKeys, StringBuilder builder) -
buildAlleleStrings
-