public final void encodeTyped(final Object value, final BCF2Type type) throws IOException { if ( value == null ) encodeTypedMissing(type); else { switch ( type ) { case INT8: case INT16: case INT32: encodeTypedInt((Integer)value, type); break; case FLOAT: encodeTypedFloat((Double) value); break; case CHAR: encodeTypedString((String) value); break; default: throw new IllegalArgumentException("Illegal type encountered " + type); } } }
public final void encodeTyped(final Object value, final BCF2Type type) throws IOException { if ( value == null ) encodeTypedMissing(type); else { switch ( type ) { case INT8: case INT16: case INT32: encodeTypedInt((Integer)value, type); break; case FLOAT: encodeTypedFloat((Double) value); break; case CHAR: encodeTypedString((String) value); break; default: throw new IllegalArgumentException("Illegal type encountered " + type); } } }
private void buildFilter( VariantContext vc ) throws IOException { if ( vc.isFiltered() ) { encodeStringsByRef(vc.getFilters()); } else if ( vc.filtersWereApplied() ) { encodeStringsByRef(Collections.singleton(VCFConstants.PASSES_FILTERS_v4)); } else { encoder.encodeTypedMissing(BCF2Type.INT8); } }
@Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTyped(final Object value, final BCF2Type type) throws IOException { if ( value == null ) encodeTypedMissing(type); else { switch ( type ) { case INT8: case INT16: case INT32: encodeTypedInt((Integer)value, type); break; case FLOAT: encodeTypedFloat((Double) value); break; case CHAR: encodeTypedString((String) value); break; default: throw new IllegalArgumentException("Illegal type encountered " + type); } } }
private void buildFilter( VariantContext vc ) throws IOException { if ( vc.isFiltered() ) { encodeStringsByRef(vc.getFilters()); } else if ( vc.filtersWereApplied() ) { encodeStringsByRef(Collections.singleton(VCFConstants.PASSES_FILTERS_v4)); } else { encoder.encodeTypedMissing(BCF2Type.INT8); } }
private void buildFilter( VariantContext vc ) throws IOException { if ( vc.isFiltered() ) { encodeStringsByRef(vc.getFilters()); } else if ( vc.filtersWereApplied() ) { encodeStringsByRef(Collections.singleton(VCFConstants.PASSES_FILTERS_v4)); } else { encoder.encodeTypedMissing(BCF2Type.INT8); } }
private final byte[] encodeRecord(final List<BCF2TypedValue> toEncode) throws IOException { BCF2Encoder encoder = new BCF2Encoder(); for ( final BCF2TypedValue tv : toEncode ) { if ( tv.isMissing() ) encoder.encodeTypedMissing(tv.type); else { final BCF2Type encodedType = encoder.encode(tv.value); if ( tv.type != null ) // only if we have an expectation Assert.assertEquals(encodedType, tv.type); } } // check output final byte[] record = encoder.getRecordBytes(); Assert.assertNotNull(record); Assert.assertTrue(record.length > 0); return record; }