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()); }
@Override public void decode(final List<Allele> siteAlleles, final String field, final BCF2Decoder decoder, final byte typeDescriptor, final int numElements, final GenotypeBuilder[] gbs) throws IOException { if ( ENABLE_FASTPATH_GT && siteAlleles.size() == 2 && numElements == 2 && gbs.length >= MIN_SAMPLES_FOR_FASTPATH_GENOTYPES ) fastBiallelicDiploidDecode(siteAlleles, decoder, typeDescriptor, gbs); else { generalDecode(siteAlleles, numElements, decoder, typeDescriptor, gbs); } }
gb.alleles(Arrays.asList(getAlleleFromEncoded(siteAlleles, a1))); } else { final Allele allele1 = getAlleleFromEncoded(siteAlleles, a1); final Allele allele2 = getAlleleFromEncoded(siteAlleles, a2); gt = Arrays.asList(allele1, allele2); allGenotypes[offset] = gt;
gb.alleles(Arrays.asList(getAlleleFromEncoded(siteAlleles, a1))); } else { final Allele allele1 = getAlleleFromEncoded(siteAlleles, a1); final Allele allele2 = getAlleleFromEncoded(siteAlleles, a2); gt = Arrays.asList(allele1, allele2); allGenotypes[offset] = gt;
gb.alleles(Arrays.asList(getAlleleFromEncoded(siteAlleles, a1))); } else { final Allele allele1 = getAlleleFromEncoded(siteAlleles, a1); final Allele allele2 = getAlleleFromEncoded(siteAlleles, a2); gt = Arrays.asList(allele1, allele2); allGenotypes[offset] = gt;
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); } } }
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); } } }
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 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()); }
@Override public void decode(final List<Allele> siteAlleles, final String field, final BCF2Decoder decoder, final byte typeDescriptor, final int numElements, final GenotypeBuilder[] gbs) throws IOException { if ( ENABLE_FASTPATH_GT && siteAlleles.size() == 2 && numElements == 2 && gbs.length >= MIN_SAMPLES_FOR_FASTPATH_GENOTYPES ) fastBiallelicDiploidDecode(siteAlleles, decoder, typeDescriptor, gbs); else { generalDecode(siteAlleles, numElements, decoder, typeDescriptor, gbs); } }
@Override public void decode(final List<Allele> siteAlleles, final String field, final BCF2Decoder decoder, final byte typeDescriptor, final int numElements, final GenotypeBuilder[] gbs) throws IOException { if ( ENABLE_FASTPATH_GT && siteAlleles.size() == 2 && numElements == 2 && gbs.length >= MIN_SAMPLES_FOR_FASTPATH_GENOTYPES ) fastBiallelicDiploidDecode(siteAlleles, decoder, typeDescriptor, gbs); else { generalDecode(siteAlleles, numElements, decoder, typeDescriptor, gbs); } }