/** Tests whether the alleles of the offspring are possible given the alleles of the parents. */ private boolean isMendelianViolation(final Genotype p1, final Genotype p2, final Genotype off) { final Allele offAllele1 = off.getAllele(0); final Allele offAllele2 = off.getAllele(1); if(p1.getAlleles().contains(offAllele1) && p2.getAlleles().contains(offAllele2)) return false; if(p2.getAlleles().contains(offAllele1) && p1.getAlleles().contains(offAllele2)) return false; return true; }
/** Tests whether the alleles of the offspring are possible given the alleles of the parents. */ private boolean isMendelianViolation(final Genotype p1, final Genotype p2, final Genotype off) { final Allele offAllele1 = off.getAllele(0); final Allele offAllele2 = off.getAllele(1); if(p1.getAlleles().contains(offAllele1) && p2.getAlleles().contains(offAllele2)) return false; if(p2.getAlleles().contains(offAllele1) && p1.getAlleles().contains(offAllele2)) return false; return true; }
/** * @return true if we're het (observed alleles differ) and neither allele is reference; if the ploidy is less than 2 or if any alleles are no-calls, this method will return false. */ public boolean isHetNonRef() { return (getType() == GenotypeType.HET && getAllele(0).isNonReference() && getAllele(1).isNonReference()); }
/** * Returns the IUPAC encoding for the given genotype or the reference base if not possible * * @param genotype the genotype to encode * @param ref the reference base * @return non-null, non-empty String of bases */ private String getIUPACbase(final Genotype genotype, final String ref) { if ( genotype == null ) throw new IllegalStateException("The genotype is null for sample " + iupacSample); // If have a spanning deletion, if both alleles are spanning deletions, use the empty allele. Otherwise, use the allele is not a // spanning deletion. if ( genotype.getAlleles().contains(Allele.SPAN_DEL) ) { if ( genotype.isHomVar() ) { return EMPTY_BASE; } else { return genotype.getAllele(0).equals(Allele.SPAN_DEL) ? genotype.getAllele(1).getBaseString() : genotype.getAllele(0).getBaseString(); } } if ( !genotype.isHet() ) return genotype.isHom() ? genotype.getAllele(0).getBaseString() : ref; final byte allele1 = genotype.getAllele(0).getBases()[0]; final byte allele2 = genotype.getAllele(1).getBases()[0]; return new String(new byte[] {BaseUtils.basesToIUPAC(allele1, allele2)}); } }
/** * @return true if we're het (observed alleles differ) and neither allele is reference; if the ploidy is less than 2 or if any alleles are no-calls, this method will return false. */ public boolean isHetNonRef() { return (getType() == GenotypeType.HET && getAllele(0).isNonReference() && getAllele(1).isNonReference()); }
if (gt.getAllele(i).equals(variantContext.getAlternateAllele(variant.getAltAlleleId()))) { isAltAllele = true;
/** * @return true if we're het (observed alleles differ) and neither allele is reference; if the ploidy is less than 2 or if any alleles are no-calls, this method will return false. */ public boolean isHetNonRef() { return (getType() == GenotypeType.HET && getAllele(0).isNonReference() && getAllele(1).isNonReference()); }
@Test(enabled = !DEBUG, dataProvider = "AlleleRemappingData") public void testAlleleRemapping(final Map<Allele, Allele> alleleMap, final int numGenotypes) { final GATKVariantContextUtils.AlleleMapper alleleMapper = new GATKVariantContextUtils.AlleleMapper(alleleMap); final GenotypesContext originalGC = createGenotypesContext(numGenotypes, new ArrayList(alleleMap.keySet())); final GenotypesContext remappedGC = GATKVariantContextUtils.updateGenotypesWithMappedAlleles(originalGC, alleleMapper); for ( int i = 0; i < numGenotypes; i++ ) { final Genotype originalG = originalGC.get(String.format("%d", i)); final Genotype remappedG = remappedGC.get(String.format("%d", i)); Assert.assertEquals(originalG.getAlleles().size(), remappedG.getAlleles().size()); for ( int j = 0; j < originalG.getAlleles().size(); j++ ) Assert.assertEquals(remappedG.getAllele(j), alleleMap.get(originalG.getAllele(j))); } }
protected List<Haplotype> getAllHaplotypes() { int numSites = genotypes.length; int[] genotypeCards = new int[numSites]; for (int i = 0; i < numSites; i++) genotypeCards[i] = genotypes[i].getPloidy(); LinkedList<Haplotype> allHaps = new LinkedList<Haplotype>(); CardinalityCounter alleleCounter = new CardinalityCounter(genotypeCards); for (int[] alleleInds : alleleCounter) { byte[] hapBases = new byte[numSites]; for (int i = 0; i < numSites; i++) { Allele alleleI = genotypes[i].getAllele(alleleInds[i]); hapBases[i] = SNPallelePair.getSingleBase(alleleI); } allHaps.add(new Haplotype(hapBases)); } return allHaps; }
@Override public void addGenotype(final BCF2Encoder encoder, final VariantContext vc, final Genotype g) throws IOException { final int samplePloidy = g.getPloidy(); for ( int i = 0; i < nValuesPerGenotype; i++ ) { if ( i < samplePloidy ) { // we encode the actual allele final Allele a = g.getAllele(i); final int offset = getAlleleOffset(a); final int encoded = ((offset+1) << 1) | ((g.isPhased() && i!=0) ? 0x01 : 0x00); encoder.encodeRawBytes(encoded, encodingType); } else { // we need to pad with missing as we have ploidy < max for this sample encoder.encodeRawBytes(encodingType.getMissingBytes(), encodingType); } } }
@Override public void addGenotype(final BCF2Encoder encoder, final VariantContext vc, final Genotype g) throws IOException { final int samplePloidy = g.getPloidy(); for ( int i = 0; i < nValuesPerGenotype; i++ ) { if ( i < samplePloidy ) { // we encode the actual allele final Allele a = g.getAllele(i); final int offset = getAlleleOffset(a); final int encoded = ((offset+1) << 1) | (g.isPhased() ? 0x01 : 0x00); encoder.encodeRawBytes(encoded, encodingType); } else { // we need to pad with missing as we have ploidy < max for this sample encoder.encodeRawBytes(encodingType.getMissingBytes(), encodingType); } } }
@Override public void addGenotype(final BCF2Encoder encoder, final VariantContext vc, final Genotype g) throws IOException { final int samplePloidy = g.getPloidy(); for ( int i = 0; i < nValuesPerGenotype; i++ ) { if ( i < samplePloidy ) { // we encode the actual allele final Allele a = g.getAllele(i); final int offset = getAlleleOffset(a); final int encoded = ((offset+1) << 1) | ((g.isPhased() && i!=0) ? 0x01 : 0x00); encoder.encodeRawBytes(encoded, encodingType); } else { // we need to pad with missing as we have ploidy < max for this sample encoder.encodeRawBytes(encodingType.getMissingBytes(), encodingType); } } }
final boolean swapped = hasGc && !gc.getAllele(0).equals(vc.getReference());
final boolean swapped = hasGc && !gc.getAllele(0).equals(vc.getReference());
final byte allele = StringUtil.toUpperCase(genotype.getAllele(0).getBases()[0]);
final byte allele = StringUtil.toUpperCase(genotype.getAllele(0).getBases()[0]);