public final int decodeNumberOfElements(final byte typeDescriptor) throws IOException { if ( BCF2Utils.sizeIsOverflow(typeDescriptor) ) // -1 ensures we explode immediately with a bad size if the result is missing return decodeInt(readTypeDescriptor(), -1); else // the size is inline, so just decode it return BCF2Utils.decodeSize(typeDescriptor); }
public static BCF2Type determineIntegerType(final int[] values) { // find the min and max values in the array int max = 0, min = 0; for ( final int v : values ) { if ( v > max ) max = v; if ( v < min ) min = v; } final BCF2Type maxType = determineIntegerType(max); final BCF2Type minType = determineIntegerType(min); // INT8 < INT16 < INT32 so this returns the larger of the two return maxType.compareTo(minType) >= 0 ? maxType : minType; }
/** * Decode an int from the stream. If the value in the stream is missing, * returns missingValue. Requires the typeDescriptor indicate an inline * single element event * * @param typeDescriptor * @return */ public final int decodeInt(final byte typeDescriptor, final int missingValue) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); final int i = decodeInt(type); return i == type.getMissingBytes() ? missingValue : i; }
public BCF2GenotypeFieldDecoders(final VCFHeader header) { // TODO -- fill in appropriate decoders for each FORMAT field in the header genotypeFieldDecoder.put(VCFConstants.GENOTYPE_KEY, new GTDecoder()); // currently the generic decoder handles FILTER values properly, in so far as we don't tolerate multiple filter field values per genotype genotypeFieldDecoder.put(VCFConstants.GENOTYPE_FILTER_KEY, new FTDecoder()); genotypeFieldDecoder.put(VCFConstants.DEPTH_KEY, new DPDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_ALLELE_DEPTHS, new ADDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_PL_KEY, new PLDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_QUALITY_KEY, new GQDecoder()); }
private final String getDictionaryString() throws IOException { return getDictionaryString((Integer) decoder.decodeTypedValue()); }
public final int[] decodeIntArray(final byte typeDescriptor, final int size) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); return decodeIntArray(size, type, null); }
private final void decodeRecord(final List<BCF2TypedValue> toEncode, final byte[] record) throws IOException { decodeRecord(toEncode, new BCF2Decoder(record)); }
@Override public void write(final int value, final OutputStream out) throws IOException { INT8.write(value, out); } };
/** * Read the size of the next block from inputStream * * @param inputStream * @return */ public final int readBlockSize(final InputStream inputStream) throws IOException { return BCF2Type.INT32.read(inputStream); }
public BCF2GenotypeFieldDecoders(final VCFHeader header) { // TODO -- fill in appropriate decoders for each FORMAT field in the header genotypeFieldDecoder.put(VCFConstants.GENOTYPE_KEY, new GTDecoder()); // currently the generic decoder handles FILTER values properly, in so far as we don't tolerate multiple filter field values per genotype genotypeFieldDecoder.put(VCFConstants.GENOTYPE_FILTER_KEY, new FTDecoder()); genotypeFieldDecoder.put(VCFConstants.DEPTH_KEY, new DPDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_ALLELE_DEPTHS, new ADDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_PL_KEY, new PLDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_QUALITY_KEY, new GQDecoder()); }
public final int decodeNumberOfElements(final byte typeDescriptor) throws IOException { if ( BCF2Utils.sizeIsOverflow(typeDescriptor) ) // -1 ensures we explode immediately with a bad size if the result is missing return decodeInt(readTypeDescriptor(), -1); else // the size is inline, so just decode it return BCF2Utils.decodeSize(typeDescriptor); }
/** * Decode an int from the stream. If the value in the stream is missing, * returns missingValue. Requires the typeDescriptor indicate an inline * single element event * * @param typeDescriptor * @return */ public final int decodeInt(final byte typeDescriptor, final int missingValue) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); final int i = decodeInt(type); return i == type.getMissingBytes() ? missingValue : i; }
private final String getDictionaryString() throws IOException { return getDictionaryString((Integer) decoder.decodeTypedValue()); }
public final int[] decodeIntArray(final byte typeDescriptor, final int size) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); return decodeIntArray(size, type, null); }
public static BCF2Type determineIntegerType(final int[] values) { // find the min and max values in the array int max = 0, min = 0; for ( final int v : values ) { if ( v > max ) max = v; if ( v < min ) min = v; } final BCF2Type maxType = determineIntegerType(max); final BCF2Type minType = determineIntegerType(min); // INT8 < INT16 < INT32 so this returns the larger of the two return maxType.compareTo(minType) >= 0 ? maxType : minType; }
@Override public int read(final InputStream in) throws IOException { final int b4 = BCF2Utils.readByte(in) & 0xFF; final int b3 = BCF2Utils.readByte(in) & 0xFF; final int b2 = BCF2Utils.readByte(in) & 0xFF; final int b1 = BCF2Utils.readByte(in) & 0xFF; return (int)(b1 << 24 | b2 << 16 | b3 << 8 | b4); }
public BCF2GenotypeFieldDecoders(final VCFHeader header) { // TODO -- fill in appropriate decoders for each FORMAT field in the header genotypeFieldDecoder.put(VCFConstants.GENOTYPE_KEY, new GTDecoder()); // currently the generic decoder handles FILTER values properly, in so far as we don't tolerate multiple filter field values per genotype genotypeFieldDecoder.put(VCFConstants.GENOTYPE_FILTER_KEY, new FTDecoder()); genotypeFieldDecoder.put(VCFConstants.DEPTH_KEY, new DPDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_ALLELE_DEPTHS, new ADDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_PL_KEY, new PLDecoder()); genotypeFieldDecoder.put(VCFConstants.GENOTYPE_QUALITY_KEY, new GQDecoder()); }
public final int[] decodeIntArray(final byte typeDescriptor, final int size) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); return decodeIntArray(size, type, null); }
@Override public int read(final InputStream in) throws IOException { final int b4 = BCF2Utils.readByte(in) & 0xFF; final int b3 = BCF2Utils.readByte(in) & 0xFF; final int b2 = BCF2Utils.readByte(in) & 0xFF; final int b1 = BCF2Utils.readByte(in) & 0xFF; return (int)(b1 << 24 | b2 << 16 | b3 << 8 | b4); }