Class BCF2FieldEncoder
java.lang.Object
htsjdk.variant.variantcontext.writer.BCF2FieldEncoder
- Direct Known Subclasses:
BCF2FieldEncoder.AtomicInt
,BCF2FieldEncoder.Flag
,BCF2FieldEncoder.Float
,BCF2FieldEncoder.GenericInts
,BCF2FieldEncoder.IntArray
,BCF2FieldEncoder.StringOrCharacter
See #BCFWriter for documentation on this classes role in encoding BCF2 files
- Since:
- 06/12
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Specialized int encoder for atomic (non-list) integersstatic class
static class
static class
static class
static class
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
encodeValue
(BCF2Encoder encoder, Object value, BCF2Type type, int minValues) Key abstract method that should encode a value of the given type into the encoder.protected final VCFHeaderLineCount
getDynamicType
(Object value) final String
getField()
final BCF2Type
final BCF2Type
Get the BCF2 type for this field, either from the static type of the field itself or by inspecting the value itself.boolean
boolean
boolean
final boolean
Is the BCF2 type of this field static, or does it have to be determine from the actual field value itself?final boolean
Is the BCF2 type of this field static, or does it have to be determine from the actual field value itself?int
int
final int
numElements
(VariantContext vc, Object value) A convenience access for the number of elements.int
numElements
(Object value) protected int
numElementsFromValue
(Object value) Given a value, return the number of elements we will encode for it.toString()
final void
writeFieldKey
(BCF2Encoder encoder) Write the field key (dictionary offset and type) into the BCF2Encoder stream
-
Method Details
-
getField
-
writeFieldKey
Write the field key (dictionary offset and type) into the BCF2Encoder stream- Parameters:
encoder
- where we write our dictionary offset- Throws:
IOException
-
toString
-
getCountType
-
hasConstantNumElements
public boolean hasConstantNumElements()- Returns:
- True if this field has a constant, fixed number of elements (such as 1 for an atomic integer)
-
hasValueDeterminedNumElements
public boolean hasValueDeterminedNumElements()- Returns:
- True if the only way to determine how many elements this field contains is by inspecting the actual value directly, such as when the number of elements is a variable length list per site or per genotype.
-
hasContextDeterminedNumElements
public boolean hasContextDeterminedNumElements()- Returns:
- True if this field has a non-fixed number of elements that depends only on the properties of the current VariantContext, such as one value per Allele or per genotype configuration.
-
numElements
public int numElements()- Returns:
- the number of elements, assuming this field has a constant number of elements.
-
numElements
- Returns:
- the number of elements by looking at the actual value provided
-
numElements
- Returns:
- the number of elements, assuming this field has context-determined number of elements.
-
numElements
A convenience access for the number of elements.- Parameters:
vc
-value
-- Returns:
- the number of encoded elements, either from the fixed number it has, from the VC, or from the value itself.
-
numElementsFromValue
Given a value, return the number of elements we will encode for it. Assumes the value is encoded as a List- Parameters:
value
-- Returns:
- the number of elements we will encode for .
-
isStaticallyTyped
public final boolean isStaticallyTyped()Is the BCF2 type of this field static, or does it have to be determine from the actual field value itself?- Returns:
- true if the field is static
-
isDynamicallyTyped
public final boolean isDynamicallyTyped()Is the BCF2 type of this field static, or does it have to be determine from the actual field value itself?- Returns:
- true if the field is not static
-
getType
Get the BCF2 type for this field, either from the static type of the field itself or by inspecting the value itself.- Returns:
- the BCF2 type for this field
-
getStaticType
-
getDynamicType
-
encodeValue
public abstract void encodeValue(BCF2Encoder encoder, Object value, BCF2Type type, int minValues) throws IOException Key abstract method that should encode a value of the given type into the encoder. Value will be of a type appropriate to the underlying encoder. If the genotype field is represented as an int[], this will be value, and the encoder needs to handle encoding all of the values in the int[]. The argument should be used, not the getType() method in the superclass as an outer loop might have decided a more general type (int16) to use, even through this encoder could have been done with int8. If minValues > 0, then encodeValue must write in at least minValues items from value. If value is atomic, this means that minValues - 1 MISSING values should be added to the encoder. If minValues is a collection type (int[]) then minValues - values.length should be added. This argument is intended to handle padding of values in genotype fields.- Parameters:
encoder
-value
-type
-minValues
-- Throws:
IOException
-