public final int[] decodeIntArray(final byte typeDescriptor, final int size) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); return decodeIntArray(size, type, null); }
public final int[] decodeIntArray(final byte typeDescriptor, final int size) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); return decodeIntArray(size, type, null); }
public final int[] decodeIntArray(final byte typeDescriptor, final int size) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); return decodeIntArray(size, type, null); }
/** * 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 */ 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 decodeTypedValue(final byte typeDescriptor, final int size) throws IOException { if ( size == 0 ) { // missing value => null in java return null; } else { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency return decodeLiteralString(size); } else if ( size == 1 ) { return decodeSingleValue(type); } else { final ArrayList<Object> ints = new ArrayList<Object>(size); for ( int i = 0; i < size; i++ ) { final Object val = decodeSingleValue(type); if ( val == null ) continue; // auto-pruning. We remove trailing nulls ints.add(val); } return ints.isEmpty() ? null : ints; // return null when all of the values are null } } }
public final Object decodeTypedValue(final byte typeDescriptor, final int size) throws IOException { if ( size == 0 ) { // missing value => null in java return null; } else { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency return decodeLiteralString(size); } else if ( size == 1 ) { return decodeSingleValue(type); } else { final ArrayList<Object> ints = new ArrayList<Object>(size); for ( int i = 0; i < size; i++ ) { final Object val = decodeSingleValue(type); if ( val == null ) continue; // auto-pruning. We remove trailing nulls ints.add(val); } return ints.isEmpty() ? null : ints; // return null when all of the values are null } } }
@Requires("size >= 0") public final Object decodeTypedValue(final byte typeDescriptor, final int size) throws IOException { if ( size == 0 ) { // missing value => null in java return null; } else { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency return decodeLiteralString(size); } else if ( size == 1 ) { return decodeSingleValue(type); } else { final ArrayList<Object> ints = new ArrayList<Object>(size); for ( int i = 0; i < size; i++ ) { final Object val = decodeSingleValue(type); if ( val == null ) continue; // auto-pruning. We remove trailing nulls ints.add(val); } return ints.isEmpty() ? null : ints; // return null when all of the values are null } } }
/** * 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; }
private final void generalDecode(final List<Allele> siteAlleles, final int ploidy, final BCF2Decoder decoder, final byte typeDescriptor, final GenotypeBuilder[] gbs) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); // a single cache for the encoded genotypes, since we don't actually need this vector final int[] tmp = new int[ploidy]; for ( final GenotypeBuilder gb : gbs ) { final int[] encoded = decoder.decodeIntArray(ploidy, type, tmp); if ( encoded == null ) // no called sample GT = . gb.alleles(null); else { assert encoded.length > 0; // we have at least some alleles to decode final List<Allele> gt = new ArrayList<Allele>(encoded.length); // note that the auto-pruning of fields magically handles different // ploidy per sample at a site for ( final int encode : encoded ) gt.add(getAlleleFromEncoded(siteAlleles, encode)); gb.alleles(gt); final boolean phased = ((encoded.length > 1 ? encoded[1] : encoded[0]) & 0x01) == 1; gb.phased(phased); } } }
private final void generalDecode(final List<Allele> siteAlleles, final int ploidy, final BCF2Decoder decoder, final byte typeDescriptor, final GenotypeBuilder[] gbs) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); // a single cache for the encoded genotypes, since we don't actually need this vector final int[] tmp = new int[ploidy]; for ( final GenotypeBuilder gb : gbs ) { final int[] encoded = decoder.decodeIntArray(ploidy, type, tmp); if ( encoded == null ) // no called sample GT = . gb.alleles(null); else { assert encoded.length > 0; // we have at least some alleles to decode final List<Allele> gt = new ArrayList<Allele>(encoded.length); // note that the auto-pruning of fields magically handles different // ploidy per sample at a site for ( final int encode : encoded ) gt.add(getAlleleFromEncoded(siteAlleles, encode)); gb.alleles(gt); final boolean phased = ((encoded.length > 1 ? encoded[1] : encoded[0]) & 0x01) == 1; gb.phased(phased); } } }
private final void generalDecode(final List<Allele> siteAlleles, final int ploidy, final BCF2Decoder decoder, final byte typeDescriptor, final GenotypeBuilder[] gbs) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); // a single cache for the encoded genotypes, since we don't actually need this vector final int[] tmp = new int[ploidy]; for ( final GenotypeBuilder gb : gbs ) { final int[] encoded = decoder.decodeIntArray(ploidy, type, tmp); if ( encoded == null ) // no called sample GT = . gb.alleles(null); else { assert encoded.length > 0; // we have at least some alleles to decode final List<Allele> gt = new ArrayList<Allele>(encoded.length); // note that the auto-pruning of fields magically handles different // ploidy per sample at a site for ( final int encode : encoded ) gt.add(getAlleleFromEncoded(siteAlleles, encode)); gb.alleles(gt); final boolean phased = (encoded[0] & 0x01) == 1; gb.phased(phased); } } }
final byte typeDescriptor, final GenotypeBuilder[] gbs) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor);
final byte typeDescriptor, final GenotypeBuilder[] gbs) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor);
final byte typeDescriptor, final GenotypeBuilder[] gbs) throws IOException { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor);