private Genotype makeGenotype(final List<Allele> alleles, boolean phase) { final GenotypeBuilder gb = new GenotypeBuilder(DUMMY_NAME, alleles); gb.phased(phase); return gb.make(); }
protected void ensureGenotypeBuilders(ProcessingContext context) { for (int i = 0; i < context.getCategoryCount(); i++) { if (genotypeBuilder.size() <= i) { genotypeBuilder.add(new GenotypeBuilder(context.getCategoryLabel(i)) .alleles(Arrays.asList(Allele.NO_CALL)) .phased(false) .noAD() .noDP() .noGQ() .noPL()); } } assert(genotypeBuilder.size() >= context.getCategoryCount()); } public IdsvVariantContextBuilder referenceReads(int[] count) {
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); } } }
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); } } }
genotypeBuilder.alleles(alleles).phased(genotype.isPhased()); break; case "AD":
gb.phased(genotypeAlleleLocation != -1 && genotypeValues.get(genotypeAlleleLocation).indexOf(VCFConstants.PHASED) != -1);
genotypeBuilder.phased(true); genotypeBuilder.attribute(VCFConstants.PHASE_SET_KEY, anchorSnp.getPos());
genotypeBuilder.phased(true); genotypeBuilder.attribute(VCFConstants.PHASE_SET_KEY, anchorSnp.getPos());
.log10PError(log10Error) .attributes(genotypeAttributes) .phased(phasedGenotype.isPhased()).make();
private VariantContext createVCGeneral(final VCFHeader header, final String chrom, final int position) { final List<Allele> alleles = new ArrayList<Allele>(); final Map<String, Object> attributes = new HashMap<String,Object>(); final GenotypesContext genotypes = GenotypesContext.create(header.getGenotypeSamples().size()); alleles.add(Allele.create("A",true)); alleles.add(Allele.create("ACC",false)); attributes.put("DP","50"); for (final String name : header.getGenotypeSamples()) { final Genotype gt = new GenotypeBuilder(name,alleles.subList(1,2)).GQ(0).attribute("BB", "1").phased(true).make(); genotypes.add(gt); } return new VariantContextBuilder("RANDOM", chrom, position, position, alleles) .genotypes(genotypes).attributes(attributes).make(); }
gb.phased(phased);
gb.phased(phased);
/** * create a fake VCF record * @param header the VCF header * @return a VCFRecord */ private VariantContext createVC(final VCFHeader header) { final List<Allele> alleles = new ArrayList<Allele>(); final Map<String, Object> attributes = new HashMap<String,Object>(); final GenotypesContext genotypes = GenotypesContext.create(header.getGenotypeSamples().size()); alleles.add(Allele.create("A",true)); alleles.add(Allele.create("ACC",false)); attributes.put("DP","50"); for (final String name : header.getGenotypeSamples()) { final Genotype gt = new GenotypeBuilder(name,alleles.subList(1,2)).GQ(0).attribute("BB", "1").phased(true).make(); genotypes.add(gt); } return new VariantContextBuilder("RANDOM", "1", 1, 1, alleles) .genotypes(genotypes).attributes(attributes).make(); } }
/** * create a fake VCF record * * @param header the VCF header * @return a VCFRecord */ private VariantContext createVC(final VCFHeader header) { final List<Allele> alleles = new ArrayList<>(); final Map<String, Object> attributes = new HashMap<>(); final GenotypesContext genotypes = GenotypesContext.create(header.getGenotypeSamples().size()); alleles.add(Allele.create("A", true)); alleles.add(Allele.create("ACC", false)); attributes.put("DP", "50"); for (final String name : header.getGenotypeSamples()) { final Genotype gt = new GenotypeBuilder(name, alleles.subList(1, 2)).GQ(0).attribute("BB", "1").phased(true) .make(); genotypes.add(gt); } return new VariantContextBuilder("RANDOM", "1", 1, 1, alleles) .genotypes(genotypes).attributes(attributes).make(); }
gb.phased(phased);
final Genotype mergedGt = new GenotypeBuilder(gt1.getSampleName(), mergedAllelesForSample).log10PError(mergedGQ).attributes(mergedGtAttribs).phased(isPhased).make(); mergedGenotypes.add(mergedGt);
/** * Copy all of the values for this builder from Genotype g * @param g * @return */ public GenotypeBuilder copy(final Genotype g) { name(g.getSampleName()); alleles(g.getAlleles()); phased(g.isPhased()); GQ(g.getGQ()); DP(g.getDP()); AD(g.getAD()); PL(g.getPL()); filter(g.getFilters()); attributes(g.getExtendedAttributes()); return this; }
/** * Copy all of the values for this builder from Genotype g * @param g * @return */ public GenotypeBuilder copy(final Genotype g) { name(g.getSampleName()); alleles(g.getAlleles()); phased(g.isPhased()); GQ(g.getGQ()); DP(g.getDP()); AD(g.getAD()); PL(g.getPL()); filter(g.getFilters()); attributes(g.getExtendedAttributes()); return this; }
/** * Copy all of the values for this builder from Genotype g * @param g * @return */ public GenotypeBuilder copy(final Genotype g) { name(g.getSampleName()); alleles(g.getAlleles()); phased(g.isPhased()); GQ(g.getGQ()); DP(g.getDP()); AD(g.getAD()); PL(g.getPL()); filter(g.getFilters()); attributes(g.getExtendedAttributes()); return this; }