private static Object splitAltAlleles(VariantContext vc) { final int numAltAlleles = vc.getAlternateAlleles().size(); if ( numAltAlleles == 1 ) return vc.getAlternateAllele(0); return vc.getAlternateAlleles(); }
/** * @return true if the alleles indicate a simple deletion (i.e., a single alt allele that is Null) */ public boolean isSimpleDeletion() { // can't just call !isSimpleInsertion() because of complex indels return isSimpleIndel() && getAlternateAllele(0).length() == 1; }
public String get(VariantContext vc) { StringBuilder x = new StringBuilder(); int n = vc.getAlternateAlleles().size(); if ( n == 0 ) return "."; for ( int i = 0; i < n; i++ ) { if ( i != 0 ) x.append(","); x.append(vc.getAlternateAllele(i)); } return x.toString(); } });
/** * @return true if the alleles indicate a simple deletion (i.e., a single alt allele that is Null) */ public boolean isSimpleDeletion() { // can't just call !isSimpleInsertion() because of complex indels return isSimpleIndel() && getAlternateAllele(0).length() == 1; }
public Allele getAltAlleleWithHighestAlleleCount() { // optimization: for bi-allelic sites, just return the only alt allele if ( isBiallelic() ) return getAlternateAllele(0); return getAlternateAlleles().stream() .max(Comparator.comparing(this::getCalledChrCount)) .orElse(null); }
/** * @return true if the alleles indicate a simple deletion (i.e., a single alt allele that is Null) */ public boolean isSimpleDeletion() { // can't just call !isSimpleInsertion() because of complex indels return isSimpleIndel() && getAlternateAllele(0).length() == 1; }
public Allele getAltAlleleWithHighestAlleleCount() { // optimization: for bi-allelic sites, just return the only alt allele if ( isBiallelic() ) return getAlternateAllele(0); return getAlternateAlleles().stream() .max(Comparator.comparing(this::getCalledChrCount)) .orElse(null); }
/** * Create a unique identifier given the variant context * * @param vc the variant context * @return non-null String */ private static String createUniqueID(final VariantContext vc) { return String.format("%d_%s_%s", vc.getStart(), vc.getReference().getDisplayString(), vc.getAlternateAllele(0).getDisplayString()); // return base + "_0," + base + "_1"; }
/** * * @return true if the variant context is a reference block * */ public boolean isReferenceBlock() { return getAlternateAlleles().size() == 1 && getAlternateAllele(0).isNonRefAllele() && getAttribute(VCFConstants.END_KEY) != null; }
private VariantContext getMatchingRecalVC(final VariantContext target, final List<VariantContext> recalVCs, final Allele allele) { for( final VariantContext recalVC : recalVCs ) { if ( target.getEnd() == recalVC.getEnd() ) { if (!useASannotations) return recalVC; else if (allele.equals(recalVC.getAlternateAllele(0))) return recalVC; } } return null; }
/** * * @return true if the variant context is a reference block * */ public boolean isReferenceBlock() { return getAlternateAlleles().size() == 1 && getAlternateAllele(0).isNonRefAllele() && getAttribute(VCFConstants.END_KEY) != null; }
private Double annotateWithPileup(final AlignmentContext stratifiedContext, final VariantContext vc) { final HashMap<Byte, MutableInt> alleleCounts = new HashMap<>(); for ( final Allele allele : vc.getAlleles() ) alleleCounts.put(allele.getBases()[0], new MutableInt(0)); for ( final byte base : stratifiedContext.getBasePileup().getBases() ) { if ( alleleCounts.containsKey(base) ) alleleCounts.get(base).increment(); } final int refCount = alleleCounts.get(vc.getReference().getBases()[0]).intValue(); final int altCount = alleleCounts.get(vc.getAlternateAllele(0).getBases()[0]).intValue(); return (refCount + altCount == 0) ? null : ((double) refCount) / (refCount + altCount); }
/** * @return true if the alleles indicate a simple indel, false otherwise. */ public boolean isSimpleIndel() { return getType() == Type.INDEL // allelic lengths differ && isBiallelic() // exactly 2 alleles && getReference().length() > 0 // ref is not null or symbolic && getAlternateAllele(0).length() > 0 // alt is not null or symbolic && getReference().getBases()[0] == getAlternateAllele(0).getBases()[0] // leading bases match for both alleles && (getReference().length() == 1 || getAlternateAllele(0).length() == 1); }
/** * @return true if the alleles indicate a simple indel, false otherwise. */ public boolean isSimpleIndel() { return getType() == Type.INDEL // allelic lengths differ && isBiallelic() // exactly 2 alleles && getReference().length() > 0 // ref is not null or symbolic && getAlternateAllele(0).length() > 0 // alt is not null or symbolic && getReference().getBases()[0] == getAlternateAllele(0).getBases()[0] // leading bases match for both alleles && (getReference().length() == 1 || getAlternateAllele(0).length() == 1); }
/** * @return true if the alleles indicate a simple indel, false otherwise. */ public boolean isSimpleIndel() { return getType() == Type.INDEL // allelic lengths differ && isBiallelic() // exactly 2 alleles && getReference().length() > 0 // ref is not null or symbolic && getAlternateAllele(0).length() > 0 // alt is not null or symbolic && getReference().getBases()[0] == getAlternateAllele(0).getBases()[0] // leading bases match for both alleles && (getReference().length() == 1 || getAlternateAllele(0).length() == 1); }
public static BaseUtils.BaseSubstitutionType getSNPSubstitutionType(VariantContext context) { if (!context.isSNP() || !context.isBiallelic()) throw new IllegalStateException("Requested SNP substitution type for bialleic non-SNP " + context); return BaseUtils.SNPSubstitutionType(context.getReference().getBases()[0], context.getAlternateAllele(0).getBases()[0]); }
@Test public void shouldPreserveSymbolicAlleleCase() { final VariantContext variant; try (final VCFFileReader reader = new VCFFileReader(new File(VariantBaseTest.variantTestDataRoot + "breakpoint.vcf"), false)) { variant = reader.iterator().next(); } // VCF v4.1 s1.4.5 // Tools processing VCF files are not required to preserve case in the allele String, except for IDs, which are case sensitive. Assert.assertTrue(variant.getAlternateAllele(0).getDisplayString().contains("chr12")); }
private VariantAnnotation annotateVariantAllele(VariantContext variantContext, int altAlleleId) { String contig = variantContext.getContig(); int pos = variantContext.getStart(); String ref = variantContext.getReference().getBaseString(); String alt = variantContext.getAlternateAllele(altAlleleId).getBaseString(); return variantAnnotator.annotate(contig, pos, ref, alt); }
private void basicInsertTest(String ref, String alt, int loc, Cigar cigar, String hap, String newHap) { final Haplotype h = new Haplotype(hap.getBytes()); final Allele h1refAllele = Allele.create(ref, true); final Allele h1altAllele = Allele.create(alt, false); final ArrayList<Allele> alleles = new ArrayList<Allele>(); alleles.add(h1refAllele); alleles.add(h1altAllele); final VariantContext vc = new VariantContextBuilder().alleles(alleles).loc("1", loc, loc + h1refAllele.getBases().length - 1).make(); h.setAlignmentStartHapwrtRef(0); h.setCigar(cigar); final Haplotype h1 = h.insertAllele(vc.getReference(), vc.getAlternateAllele(0), loc, vc.getStart()); final Haplotype h1expected = new Haplotype(newHap.getBytes()); Assert.assertEquals(h1, h1expected); }
private VariantContext makeDeletion(final String contig, final int start, final int size) { final String del = Utils.dupString("A", size); final String alt = del.substring(0, 1); final VariantContext vc = GATKVariantContextUtils.makeFromAlleles("test", contig, start, Arrays.asList(del, alt)); final VariantContextBuilder vcb = new VariantContextBuilder(vc); final GenotypeBuilder gb = new GenotypeBuilder(SAMPLE_NAME, Arrays.asList(vc.getReference(), vc.getAlternateAllele(0))); gb.GQ(50); gb.DP(10); gb.AD(new int[]{1, 2}); gb.PL(new int[]{0, 10, 100}); return vcb.genotypes(gb.make()).make(); }