public static boolean hasSymbolicAlleles( final List<Allele> alleles ) { for ( final Allele a: alleles ) { if (a.isSymbolic()) { return true; } } return false; }
public static boolean hasSymbolicAlleles( final List<Allele> alleles ) { for (int i = 0, size = alleles.size(); i < size; i++ ) { if (alleles.get(i).isSymbolic()) { return true; } } return false; }
public static boolean hasSymbolicAlleles( final List<Allele> alleles ) { for (int i = 0, size = alleles.size(); i < size; i++ ) { if (alleles.get(i).isSymbolic()) { return true; } } return false; }
/** * @param list the original alleles list * @return a non-null list of non-symbolic alleles */ private static List<Allele> nonSymbolicAlleles(final List<Allele> list) { final List<Allele> result = new ArrayList<>(list.size()); for ( final Allele allele : list ) { if ( !allele.isSymbolic() ) { result.add(allele); } } return result; }
static private boolean isUsableAlternateAllele(final Allele allele) { return ! (allele.isReference() || allele.isSymbolic() || allele == Allele.SPAN_DEL ); }
private static Type typeOfBiallelicVariant(Allele ref, Allele allele) { if ( ref.isSymbolic() ) throw new IllegalStateException("Unexpected error: encountered a record with a symbolic reference allele"); if ( allele.isSymbolic() ) return Type.SYMBOLIC; if ( ref.length() == allele.length() ) { if ( allele.length() == 1 ) return Type.SNP; else return Type.MNP; } // Important note: previously we were checking that one allele is the prefix of the other. However, that's not an // appropriate check as can be seen from the following example: // REF = CTTA and ALT = C,CT,CA // This should be assigned the INDEL type but was being marked as a MIXED type because of the prefix check. // In truth, it should be absolutely impossible to return a MIXED type from this method because it simply // performs a pairwise comparison of a single alternate allele against the reference allele (whereas the MIXED type // is reserved for cases of multiple alternate alleles of different types). Therefore, if we've reached this point // in the code (so we're not a SNP, MNP, or symbolic allele), we absolutely must be an INDEL. return Type.INDEL; // old incorrect logic: // if (oneIsPrefixOfOther(ref, allele)) // return Type.INDEL; // else // return Type.MIXED; }
@Test public void testBreakpointSymbolicBreakend() { Assert.assertTrue(Allele.create("A[<contig>:1[").isSymbolic()); Assert.assertTrue(Allele.create("A]<contig>:1]").isSymbolic()); Assert.assertTrue(Allele.create("]<contig>:1]A").isSymbolic()); Assert.assertTrue(Allele.create("[<contig>:1[A").isSymbolic()); }
public static Allele extend(final Allele left, final byte[] right) { if (left.isSymbolic()) throw new IllegalArgumentException("Cannot extend a symbolic allele"); byte[] bases = new byte[left.length() + right.length]; System.arraycopy(left.getBases(), 0, bases, 0, left.length()); System.arraycopy(right, 0, bases, left.length(), right.length); return create(bases, left.isReference()); }
public static Allele extend(Allele left, byte[] right) { if (left.isSymbolic()) throw new IllegalArgumentException("Cannot extend a symbolic allele"); byte[] bases = new byte[left.length() + right.length]; System.arraycopy(left.getBases(), 0, bases, 0, left.length()); System.arraycopy(right, 0, bases, left.length(), right.length); return create(bases, left.isReference()); }
public static Allele extend(final Allele left, final byte[] right) { if (left.isSymbolic()) throw new IllegalArgumentException("Cannot extend a symbolic allele"); byte[] bases = new byte[left.length() + right.length]; System.arraycopy(left.getBases(), 0, bases, 0, left.length()); System.arraycopy(right, 0, bases, left.length(), right.length); return create(bases, left.isReference()); }
@Test public void testInsSymbolicShorthand() { Assert.assertTrue(Allele.create("A<ctg1>").isSymbolic()); Assert.assertTrue(Allele.create("<ctg1>A").isSymbolic()); }
@Test public void testTelomericBreakend() { Assert.assertTrue(Allele.create(".[1:10]").isSymbolic()); Assert.assertTrue(Allele.create("[1:10].").isSymbolic()); }
@Test public void testBreakpoint() { Allele a = Allele.create("A[chr1:1["); Assert.assertTrue(a.isSymbolic()); Assert.assertEquals("A[chr1:1[", a.getDisplayString()); Assert.assertTrue(Allele.create("]chr1:1]A").isSymbolic()); Assert.assertTrue(Allele.create("[chr1:1[A").isSymbolic()); Assert.assertTrue(Allele.create("A]chr1:1]").isSymbolic()); }
@Test public void testVCF42Breakend() { Allele a; a = Allele.create("A."); Assert.assertTrue(a.isSymbolic()); Assert.assertEquals("A.", a.getDisplayString()); a = Allele.create(".A"); Assert.assertTrue(a.isSymbolic()); Assert.assertEquals(".A", a.getDisplayString()); Assert.assertTrue(Allele.create("AA.").isSymbolic()); Assert.assertTrue(Allele.create(".AA").isSymbolic()); }
@Test public void testSymbolic() { Allele a = Allele.create("<SYMBOLIC>"); Assert.assertTrue(a.isSymbolic()); Assert.assertEquals("<SYMBOLIC>", a.getDisplayString()); }
protected static boolean checkVariationClass( final VariantContext evalVC, final Allele allele, final VariantRecalibratorArgumentCollection.Mode mode ) { switch( mode ) { case SNP: //note that spanning deletions are considered SNPs by this logic return evalVC.getReference().length() == allele.length(); case INDEL: return (evalVC.getReference().length() != allele.length()) || allele.isSymbolic(); case BOTH: return true; default: throw new IllegalStateException( "Encountered unknown recal mode: " + mode ); } }
private void putTsTv(VariantContext vc, String sampleName, int alleleIdx) { final Statistics stats = perSampleStats.get(sampleName); final Allele ref = vc.getReference(); final Allele alt = vc.getAlleles().get(alleleIdx); // Consider ts/tv if it is a SNV if (ref.length() == 1 && !alt.isSymbolic() && alt.length() == 1) { final String refStr = ref.getBaseString().toUpperCase(); final String altStr = alt.getBaseString().toUpperCase(); if (isTransition(refStr, altStr)) stats.putTsTv(TsTv.TS); else if (isTransversion(refStr, altStr)) stats.putTsTv(TsTv.TV); } }
private static Allele reverseComplement(final Allele oldAllele, final Interval target, final ReferenceSequence referenceSequence, final boolean isIndel, final boolean addToStart) { if (oldAllele.isSymbolic() || oldAllele.isNoCall()) { return oldAllele; } else if (isIndel) { // target.getStart is 1-based, reference bases are 0-based final StringBuilder alleleBuilder = new StringBuilder(target.getEnd() - target.getStart() + 1); if (addToStart) { alleleBuilder.append((char) referenceSequence.getBases()[target.getStart() - 2]); } alleleBuilder.append(SequenceUtil.reverseComplement(oldAllele.getBaseString().substring(1, oldAllele.length()))); if (!addToStart) { alleleBuilder.append((char) referenceSequence.getBases()[target.getEnd() - 1]); } return Allele.create(alleleBuilder.toString(), oldAllele.isReference()); } else { return Allele.create(SequenceUtil.reverseComplement(oldAllele.getBaseString()), oldAllele.isReference()); } }
private static Allele reverseComplement(final Allele oldAllele, final Interval target, final ReferenceSequence referenceSequence, final boolean isIndel, final boolean addToStart) { if (oldAllele.isSymbolic() || oldAllele.isNoCall()) { return oldAllele; } else if (isIndel) { // target.getStart is 1-based, reference bases are 0-based final StringBuilder alleleBuilder = new StringBuilder(target.getEnd() - target.getStart() + 1); if (addToStart) { alleleBuilder.append((char) referenceSequence.getBases()[target.getStart() - 2]); } alleleBuilder.append(SequenceUtil.reverseComplement(oldAllele.getBaseString().substring(1, oldAllele.length()))); if (!addToStart) { alleleBuilder.append((char) referenceSequence.getBases()[target.getEnd() - 1]); } return Allele.create(alleleBuilder.toString(), oldAllele.isReference()); } else { return Allele.create(SequenceUtil.reverseComplement(oldAllele.getBaseString()), oldAllele.isReference()); } }
public static int computeReverseClipping(final List<Allele> unclippedAlleles, final byte[] ref) { int clipping = 0; boolean stillClipping = true; while ( stillClipping ) { for ( final Allele a : unclippedAlleles ) { if ( a.isSymbolic() ) continue; // we need to ensure that we don't reverse clip out all of the bases from an allele because we then will have the wrong // position set for the VariantContext (although it's okay to forward clip it all out, because the position will be fine). if ( a.length() - clipping == 0 ) return clipping - 1; if ( a.length() - clipping <= 0 || a.length() == 0 ) { stillClipping = false; } else if ( ref.length == clipping ) { return -1; } else if ( a.getBases()[a.length()-clipping-1] != ref[ref.length-clipping-1] ) { stillClipping = false; } } if ( stillClipping ) clipping++; } return clipping; }