Package htsjdk.variant.vcf
Class VCFEncoder
- java.lang.Object
-
- htsjdk.variant.vcf.VCFEncoder
-
public class VCFEncoder extends Object
Functions specific to encoding VCF records.
-
-
Field Summary
Fields Modifier and Type Field Description static Charset
VCF_CHARSET
The encoding used for VCF files: ISO-8859-1
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addGenotypeData(VariantContext vc, Map<Allele,String> alleleMap, List<String> genotypeFormatKeys, StringBuilder builder)
Map<Allele,String>
buildAlleleStrings(VariantContext vc)
String
encode(VariantContext context)
encodes aVariantContext
as a VCF line Depending on the use case it may be more efficient towrite(Appendable, VariantContext)
directly instead of creating an intermediate string.static String
formatVCFDouble(double d)
Takes a double value and pretty prints it to a String for displayvoid
setAllowMissingFieldsInHeader(boolean allow)
Deprecated.since 10/24/13 use the constructorvoid
setVCFHeader(VCFHeader header)
Deprecated.since 10/24/13 use the constructorvoid
write(Appendable vcfOutput, VariantContext context)
encodes aVariantContext
context as VCF, and writes it directly to anAppendable
This may be more efficient than callingencode(VariantContext)
and then writing the result since it avoids creating an intermediate string.
-
-
-
Field Detail
-
VCF_CHARSET
public static final Charset VCF_CHARSET
The encoding used for VCF files: ISO-8859-1
-
-
Constructor Detail
-
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 Detail
-
setVCFHeader
@Deprecated public void setVCFHeader(VCFHeader header)
Deprecated.since 10/24/13 use the constructor
-
setAllowMissingFieldsInHeader
@Deprecated public void setAllowMissingFieldsInHeader(boolean allow)
Deprecated.since 10/24/13 use the constructor
-
encode
public String encode(VariantContext context)
encodes aVariantContext
as 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
public void write(Appendable vcfOutput, VariantContext context) throws IOException
encodes aVariantContext
context as VCF, and writes it directly to anAppendable
This may be more efficient than callingencode(VariantContext)
and then writing the result since it avoids creating an intermediate string.- Parameters:
vcfOutput
- theAppendable
to write tocontext
- the variant- Throws:
IOException
-
formatVCFDouble
public static String formatVCFDouble(double d)
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
public Map<Allele,String> buildAlleleStrings(VariantContext vc)
-
-