@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; if ( value != null ) { encoder.encodeRawInt((Integer)value, type); count++; } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; if ( value != null ) { encoder.encodeRawInt((Integer)value, type); count++; } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; if ( value != null ) { for ( final int i : (int[])value ) { encoder.encodeRawInt(i, type); count++; } } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; if ( value != null ) { encoder.encodeRawInt((Integer)value, type); count++; } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
public final void encodeTypedInt(final int v, final BCF2Type type) throws IOException { encodeType(1, type); encodeRawInt(v, type); }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; for ( final Integer i : toList(Integer.class, value) ) { if ( i != null ) { // necessary because .,. => [null, null] in VC encoder.encodeRawInt(i, type); count++; } } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; if ( value != null ) { for ( final int i : (int[])value ) { encoder.encodeRawInt(i, type); count++; } } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
public final void encodeTypedInt(final int v, final BCF2Type type) throws IOException { encodeType(1, type); encodeRawInt(v, type); }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; for ( final Integer i : BCF2Utils.toList(Integer.class, value) ) { if ( i != null ) { // necessary because .,. => [null, null] in VC encoder.encodeRawInt(i, type); count++; } } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Requires("value == null || ((int[])value).length <= minValues") @Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; if ( value != null ) { for ( final int i : (int[])value ) { encoder.encodeRawInt(i, type); count++; } } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Override public void encodeValue(final BCF2Encoder encoder, final Object value, final BCF2Type type, final int minValues) throws IOException { int count = 0; for ( final Integer i : BCF2Utils.toList(Integer.class, value) ) { if ( i != null ) { // necessary because .,. => [null, null] in VC encoder.encodeRawInt(i, type); count++; } } for ( ; count < minValues; count++ ) encoder.encodeRawMissingValue(type); } }
@Requires("type.isIntegerType()") @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTypedInt(final int v, final BCF2Type type) throws IOException { encodeType(1, type); encodeRawInt(v, type); }
private byte[] buildSitesData( VariantContext vc ) throws IOException { final int contigIndex = contigDictionary.get(vc.getContig()); if ( contigIndex == -1 ) throw new IllegalStateException(String.format("Contig %s not found in sequence dictionary from reference", vc.getContig())); // note use of encodeRawValue to not insert the typing byte encoder.encodeRawValue(contigIndex, BCF2Type.INT32); // pos. GATK is 1 based, BCF2 is 0 based encoder.encodeRawValue(vc.getStart() - 1, BCF2Type.INT32); // ref length. GATK is closed, but BCF2 is open so the ref length is GATK end - GATK start + 1 // for example, a SNP is in GATK at 1:10-10, which has ref length 10 - 10 + 1 = 1 encoder.encodeRawValue(vc.getEnd() - vc.getStart() + 1, BCF2Type.INT32); // qual if ( vc.hasLog10PError() ) encoder.encodeRawFloat((float) vc.getPhredScaledQual()); else encoder.encodeRawMissingValue(BCF2Type.FLOAT); // info fields final int nAlleles = vc.getNAlleles(); final int nInfo = vc.getAttributes().size(); final int nGenotypeFormatFields = getNGenotypeFormatFields(vc); final int nSamples = header.getNGenotypeSamples(); encoder.encodeRawInt((nAlleles << 16) | (nInfo & 0x0000FFFF), BCF2Type.INT32); encoder.encodeRawInt((nGenotypeFormatFields << 24) | (nSamples & 0x00FFFFF), BCF2Type.INT32); buildID(vc); buildAlleles(vc); buildFilter(vc); buildInfo(vc); return encoder.getRecordBytes(); }
private byte[] buildSitesData( VariantContext vc ) throws IOException { final int contigIndex = contigDictionary.get(vc.getContig()); if ( contigIndex == -1 ) throw new IllegalStateException(String.format("Contig %s not found in sequence dictionary from reference", vc.getContig())); // note use of encodeRawValue to not insert the typing byte encoder.encodeRawValue(contigIndex, BCF2Type.INT32); // pos. GATK is 1 based, BCF2 is 0 based encoder.encodeRawValue(vc.getStart() - 1, BCF2Type.INT32); // ref length. GATK is closed, but BCF2 is open so the ref length is GATK end - GATK start + 1 // for example, a SNP is in GATK at 1:10-10, which has ref length 10 - 10 + 1 = 1 encoder.encodeRawValue(vc.getEnd() - vc.getStart() + 1, BCF2Type.INT32); // qual if ( vc.hasLog10PError() ) encoder.encodeRawFloat((float) vc.getPhredScaledQual()); else encoder.encodeRawMissingValue(BCF2Type.FLOAT); // info fields final int nAlleles = vc.getNAlleles(); final int nInfo = vc.getAttributes().size(); final int nGenotypeFormatFields = getNGenotypeFormatFields(vc); final int nSamples = header.getNGenotypeSamples(); encoder.encodeRawInt((nAlleles << 16) | (nInfo & 0x0000FFFF), BCF2Type.INT32); encoder.encodeRawInt((nGenotypeFormatFields << 24) | (nSamples & 0x00FFFFF), BCF2Type.INT32); buildID(vc); buildAlleles(vc); buildFilter(vc); buildInfo(vc); return encoder.getRecordBytes(); }
private byte[] buildSitesData( VariantContext vc ) throws IOException { final int contigIndex = contigDictionary.get(vc.getChr()); if ( contigIndex == -1 ) throw new IllegalStateException(String.format("Contig %s not found in sequence dictionary from reference", vc.getChr())); // note use of encodeRawValue to not insert the typing byte encoder.encodeRawValue(contigIndex, BCF2Type.INT32); // pos. GATK is 1 based, BCF2 is 0 based encoder.encodeRawValue(vc.getStart() - 1, BCF2Type.INT32); // ref length. GATK is closed, but BCF2 is open so the ref length is GATK end - GATK start + 1 // for example, a SNP is in GATK at 1:10-10, which has ref length 10 - 10 + 1 = 1 encoder.encodeRawValue(vc.getEnd() - vc.getStart() + 1, BCF2Type.INT32); // qual if ( vc.hasLog10PError() ) encoder.encodeRawFloat((float) vc.getPhredScaledQual()); else encoder.encodeRawMissingValue(BCF2Type.FLOAT); // info fields final int nAlleles = vc.getNAlleles(); final int nInfo = vc.getAttributes().size(); final int nGenotypeFormatFields = getNGenotypeFormatFields(vc); final int nSamples = header.getNGenotypeSamples(); encoder.encodeRawInt((nAlleles << 16) | (nInfo & 0x0000FFFF), BCF2Type.INT32); encoder.encodeRawInt((nGenotypeFormatFields << 24) | (nSamples & 0x00FFFFF), BCF2Type.INT32); buildID(vc); buildAlleles(vc); buildFilter(vc); buildInfo(vc); return encoder.getRecordBytes(); }