/** * Creates a non-Ref allele. @see Allele(byte[], boolean) for full information * * @param bases bases representing an allele */ public static Allele create(final String bases) { return create(bases, false); }
/** * Creates a non-Ref allele. @see Allele(byte[], boolean) for full information * * @param bases bases representing an allele */ public static Allele create(String bases) { return create(bases, false); }
public List<Allele> truthAlleles() { if (allAlleles.isEmpty() || this.truthAllele1 == null) { return Collections.emptyList(); } else { final Allele truthAllele1 = Allele.create(this.truthAllele1, this.allAlleles.indexOf(this.truthAllele1) == 0); final Allele truthAllele2 = Allele.create(this.truthAllele2, this.allAlleles.indexOf(this.truthAllele2) == 0); return Arrays.asList(truthAllele1, truthAllele2); } }
public List<Allele> callAlleles() { if (allAlleles.isEmpty() || this.callAllele1 == null) { return Collections.emptyList(); } else { final Allele callAllele1 = Allele.create(this.callAllele1, this.allAlleles.indexOf(this.callAllele1) == 0); final Allele callAllele2 = Allele.create(this.callAllele2, this.allAlleles.indexOf(this.callAllele2) == 0); return Arrays.asList(callAllele1, callAllele2); } } }
public List<Allele> truthAlleles() { if (allAlleles.isEmpty() || this.truthAllele1 == null) { return Collections.emptyList(); } else { final Allele truthAllele1 = Allele.create(this.truthAllele1, this.allAlleles.indexOf(this.truthAllele1) == 0); final Allele truthAllele2 = Allele.create(this.truthAllele2, this.allAlleles.indexOf(this.truthAllele2) == 0); return Arrays.asList(truthAllele1, truthAllele2); } }
/** * Create angle-bracketed alt allele for simple SV types * @return angle-bracketed alt allele for simple SV types * @throws UnsupportedOperationException if this is invoked on a {@link #BND} object */ Allele toSymbolicAltAllele() { if (this.equals(StructuralVariantType.BND)) { throw new UnsupportedOperationException("BND type does not have angle bracketed alt allele"); } return Allele.create("<" + name() + ">", false); } }
/** * parse a single allele, given the allele list * @param alleles the alleles available * @param alt the allele to parse * @param lineNo the line number for this record */ private static void parseSingleAltAllele(List<Allele> alleles, String alt, int lineNo) { checkAllele(alt, false, lineNo); Allele allele = Allele.create(alt, false); if ( ! allele.isNoCall() ) alleles.add(allele); }
/** * parse a single allele, given the allele list * @param alleles the alleles available * @param alt the allele to parse * @param lineNo the line number for this record */ private static void parseSingleAltAllele(List<Allele> alleles, String alt, int lineNo) { checkAllele(alt, false, lineNo); Allele allele = Allele.create(alt, false); if ( ! allele.isNoCall() ) alleles.add(allele); }
public List<Allele> asList() { if (allAlleles.isEmpty()) { return Collections.emptyList(); } else { final List<Allele> alleles = new ArrayList<>(this.allAlleles.size()); for (int idx = 0; idx < this.allAlleles.size(); idx++) { alleles.add(Allele.create(this.allAlleles.get(idx), idx == 0)); } return alleles; } }
public List<Allele> asList() { if (allAlleles.isEmpty()) { return Collections.emptyList(); } else { final List<Allele> alleles = new ArrayList<>(this.allAlleles.size()); for (int idx = 0; idx < this.allAlleles.size(); idx++) { alleles.add(Allele.create(this.allAlleles.get(idx), idx == 0)); } return alleles; } }
private static VariantContext buildVariantContext(final String source, final String contig, final long start) { final Collection<Allele> alleles = new ArrayList<Allele>(); alleles.add(Allele.create("AAAA", true)); alleles.add(Allele.create("AAGG", false)); return new VariantContextBuilder(source, contig, start, start + 3, alleles).make(); }
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 code that creates VariantContexts */ @Test() public void testWithVariantContext() throws Exception { final List<Allele> alleles = Arrays.asList(Allele.create("A", true), Allele.create("C")); final VariantContext vc = new VariantContextBuilder("test", "1", 10, 10, alleles).make(); Assert.assertTrue(vc.getAlleles().size() >= 0); // TODO -- add some tests that use VariantContext } }
@Test(enabled = !DEBUG, dataProvider = "ForwardClippingData") public void testForwardClipping(final List<String> alleleStrings, final int expectedClip) { final List<Allele> alleles = new LinkedList<Allele>(); for ( final String alleleString : alleleStrings ) alleles.add(Allele.create(alleleString)); for ( final List<Allele> myAlleles : Utils.makePermutations(alleles, alleles.size(), false)) { final int actual = GATKVariantContextUtils.computeForwardClipping(myAlleles); Assert.assertEquals(actual, expectedClip); } }
@Test public void testExtend() { Assert.assertEquals("AT", Allele.extend(Allele.create("A"), "T".getBytes()).toString()); Assert.assertEquals("ATA", Allele.extend(Allele.create("A"), "TA".getBytes()).toString()); Assert.assertEquals("A", Allele.extend(Allele.NO_CALL, "A".getBytes()).toString()); Assert.assertEquals("ATCGA", Allele.extend(Allele.create("AT"), "CGA".getBytes()).toString()); Assert.assertEquals("ATCGA", Allele.extend(Allele.create("ATC"), "GA".getBytes()).toString()); } }
@Test public void testMakeNewSACs(){ int[] expected = {10, 20} ; final Genotype g = new GenotypeBuilder().alleles(Arrays.asList(Allele.create("A", true), Allele.create("G"))). attribute(GATKVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY, new int[]{5, 10, 15, 20}).make(); Assert.assertEquals(GATKVariantContextUtils.makeNewSACs(g, Arrays.asList(1, 3)), expected); }
@Test public void testCreateAlleleMapping(){ final List<Allele> alleles = Arrays.asList(Aref,Symbolic,T); final VariantContext vc = new VariantContextBuilder().chr("chr1").alleles(alleles).make(); Map<Allele, Allele> map = GATKVariantContextUtils.createAlleleMapping(ATref, vc, alleles); final List<Allele> expectedAlleles = Arrays.asList(Allele.create("<Symbolic>", false), Allele.create("TT", false)); for ( int i = 0; i < vc.getAlternateAlleles().size(); i++ ){ Assert.assertEquals(map.get(vc.getAlternateAlleles().get(i)), expectedAlleles.get(i)); } }
@Test public void testReverseComplementFailureDoesNotErrorOut() { final VariantContextBuilder builder = new VariantContextBuilder().source("test").loc("chr1", 1, 4); final Allele originalRef = Allele.create("CCCC", true); final Allele originalAlt = Allele.create("C", false); builder.alleles(Arrays.asList(originalRef, originalAlt)); final Interval interval = new Interval("chr1", 1, 4, true, "test "); final String reference = "ATGATGATGA"; final ReferenceSequence refSeq = new ReferenceSequence("chr1", 10, reference.getBytes()); // we don't actually care what the results are here -- we just want to make sure that it doesn't fail final VariantContextBuilder result = LiftoverUtils.reverseComplementVariantContext(builder.make(), interval, refSeq); }