public final void encodeRawMissingValue(final BCF2Type type) throws IOException { encodeRawBytes(type.getMissingBytes(), type); }
public final void encodeRawMissingValue(final BCF2Type type) throws IOException { encodeRawBytes(type.getMissingBytes(), type); }
/** * 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; }
@Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeRawMissingValue(final BCF2Type type) throws IOException { encodeRawBytes(type.getMissingBytes(), type); }
/** * 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; }
/** * 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 */ @Requires("BCF2Utils.decodeSize(typeDescriptor) == 1") 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 final Object decodeSingleValue(final BCF2Type type) throws IOException { // TODO -- decodeTypedValue should integrate this routine final int value = decodeInt(type); if ( value == type.getMissingBytes() ) return null; else { switch (type) { case INT8: case INT16: case INT32: return value; case FLOAT: return rawFloatToFloat(value); case CHAR: return value & 0xFF; // TODO -- I cannot imagine why we'd get here, as string needs to be special cased default: throw new TribbleException("BCF2 codec doesn't know how to decode type " + type ); } } }
public final Object decodeSingleValue(final BCF2Type type) throws IOException { // TODO -- decodeTypedValue should integrate this routine final int value = decodeInt(type); if ( value == type.getMissingBytes() ) return null; else { switch (type) { case INT8: case INT16: case INT32: return value; case FLOAT: return rawFloatToFloat(value); case CHAR: return value & 0xFF; // TODO -- I cannot imagine why we'd get here, as string needs to be special cased default: throw new TribbleException("BCF2 codec doesn't know how to decode type " + type ); } } }
public final Object decodeSingleValue(final BCF2Type type) throws IOException { // TODO -- decodeTypedValue should integrate this routine final int value = decodeInt(type); if ( value == type.getMissingBytes() ) return null; else { switch (type) { case INT8: case INT16: case INT32: return value; case FLOAT: return rawFloatToFloat(value); case CHAR: return value & 0xFF; // TODO -- I cannot imagine why we'd get here, as string needs to be special cased default: throw new TribbleException("BCF2 codec doesn't know how to decode type " + type ); } } }
if ( val1 == type.getMissingBytes() ) { for ( int i = 1; i < size; i++ ) { ints[i] = decodeInt(type); if ( ints[i] == type.getMissingBytes() ) {
if ( val1 == type.getMissingBytes() ) { for ( int i = 1; i < size; i++ ) { ints[i] = decodeInt(type); if ( ints[i] == type.getMissingBytes() ) {
if ( val1 == type.getMissingBytes() ) { for ( int i = 1; i < size; i++ ) { ints[i] = decodeInt(type); if ( ints[i] == type.getMissingBytes() ) {
final int a2 = decoder.decodeInt(type); if ( a1 == type.getMissingBytes() ) { assert a2 == type.getMissingBytes(); } else if ( a2 == type.getMissingBytes() ) { gb.alleles(Arrays.asList(getAlleleFromEncoded(siteAlleles, a1))); } else {
final int a2 = decoder.decodeInt(type); if ( a1 == type.getMissingBytes() ) { assert a2 == type.getMissingBytes(); } else if ( a2 == type.getMissingBytes() ) { gb.alleles(Arrays.asList(getAlleleFromEncoded(siteAlleles, a1))); } else {
final int a2 = decoder.decodeInt(type); if ( a1 == type.getMissingBytes() ) { assert a2 == type.getMissingBytes(); } else if ( a2 == type.getMissingBytes() ) { gb.alleles(Arrays.asList(getAlleleFromEncoded(siteAlleles, a1))); } else {
@Override public void addGenotype(final BCF2Encoder encoder, final VariantContext vc, final Genotype g) throws IOException { final int samplePloidy = g.getPloidy(); for ( int i = 0; i < nValuesPerGenotype; i++ ) { if ( i < samplePloidy ) { // we encode the actual allele final Allele a = g.getAllele(i); final int offset = getAlleleOffset(a); final int encoded = ((offset+1) << 1) | ((g.isPhased() && i!=0) ? 0x01 : 0x00); encoder.encodeRawBytes(encoded, encodingType); } else { // we need to pad with missing as we have ploidy < max for this sample encoder.encodeRawBytes(encodingType.getMissingBytes(), encodingType); } } }
@Override public void addGenotype(final BCF2Encoder encoder, final VariantContext vc, final Genotype g) throws IOException { final int samplePloidy = g.getPloidy(); for ( int i = 0; i < nValuesPerGenotype; i++ ) { if ( i < samplePloidy ) { // we encode the actual allele final Allele a = g.getAllele(i); final int offset = getAlleleOffset(a); final int encoded = ((offset+1) << 1) | ((g.isPhased() && i!=0) ? 0x01 : 0x00); encoder.encodeRawBytes(encoded, encodingType); } else { // we need to pad with missing as we have ploidy < max for this sample encoder.encodeRawBytes(encodingType.getMissingBytes(), encodingType); } } }
@Override public void addGenotype(final BCF2Encoder encoder, final VariantContext vc, final Genotype g) throws IOException { final int samplePloidy = g.getPloidy(); for ( int i = 0; i < nValuesPerGenotype; i++ ) { if ( i < samplePloidy ) { // we encode the actual allele final Allele a = g.getAllele(i); final int offset = getAlleleOffset(a); final int encoded = ((offset+1) << 1) | (g.isPhased() ? 0x01 : 0x00); encoder.encodeRawBytes(encoded, encodingType); } else { // we need to pad with missing as we have ploidy < max for this sample encoder.encodeRawBytes(encodingType.getMissingBytes(), encodingType); } } }