use of htsjdk.variant.variantcontext.Allele in project gatk by broadinstitute.
the class AlleleSpecificAnnotationDataUnitTest method testTwoRef.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testTwoRef() throws Exception {
final Allele Aref = Allele.create("A", true);
final Allele Tref = Allele.create("T", true);
final List<Allele> alleles = Arrays.asList(Aref, Tref);
String rawData = "1|2";
new AlleleSpecificAnnotationData<>(alleles, rawData);
}
use of htsjdk.variant.variantcontext.Allele in project gatk by broadinstitute.
the class AlleleSpecificAnnotationDataUnitTest method testCreate.
@Test
public void testCreate() throws Exception {
final Allele Aref = Allele.create("A", true);
final Allele T = Allele.create("T", false);
final List<Allele> alleles = Arrays.asList(Aref, T);
String rawData = "1|2";
final AlleleSpecificAnnotationData<Integer> asad = new AlleleSpecificAnnotationData<>(alleles, rawData);
Assert.assertEquals(asad.getAlleles(), alleles);
Assert.assertEquals(asad.getRefAllele(), Aref);
Assert.assertNull(asad.getAttribute(Aref));
Assert.assertNull(asad.getAttribute(T));
Assert.assertEquals(asad.getRawData(), rawData);
final Map<Allele, Integer> map = new HashMap<>();
map.put(Aref, 10);
map.put(T, 11);
asad.setAttributeMap(map);
Assert.assertEquals(asad.getAttribute(Aref), (Integer) 10);
Assert.assertEquals(asad.getAttribute(T), (Integer) 11);
}
use of htsjdk.variant.variantcontext.Allele in project gatk by broadinstitute.
the class AlleleListUnitTest method testShufflePermutation.
@Test(dataProvider = "singleAlleleListData", dependsOnMethods = { "testAsList", "testEquals" })
public void testShufflePermutation(final List<Allele> alleles1) {
final AlleleList<Allele> originalAlleleList = new IndexedAlleleList<>(alleles1);
if (originalAlleleList.numberOfAlleles() <= 1) {
//return because this input is invalid for this test
return;
}
final Allele[] targetAlleleArray = originalAlleleList.asListOfAlleles().toArray(new Allele[originalAlleleList.numberOfAlleles()]);
final int[] fromIndex = new int[targetAlleleArray.length];
for (int i = 0; i < fromIndex.length; i++) fromIndex[i] = i;
for (int i = 0; i < targetAlleleArray.length - 1; i++) {
final int swapIndex = rnd.nextInt(targetAlleleArray.length - i - 1);
final int otherIndex = fromIndex[swapIndex + i + 1];
final Allele other = targetAlleleArray[swapIndex + i + 1];
fromIndex[swapIndex + i + 1] = fromIndex[i];
fromIndex[i] = otherIndex;
targetAlleleArray[swapIndex + i + 1] = targetAlleleArray[i];
targetAlleleArray[i] = other;
}
final AlleleList<Allele> targetAlleleList = new IndexedAlleleList<>(targetAlleleArray);
final AlleleListPermutation<Allele> permutation = originalAlleleList.permutation(targetAlleleList);
Assert.assertFalse(permutation.isNonPermuted());
AlleleListUnitTester.assertAlleleList(originalAlleleList, permutation.fromList());
AlleleListUnitTester.assertAlleleList(targetAlleleList, permutation.toList());
Assert.assertFalse(permutation.isPartial());
Assert.assertEquals(permutation.fromSize(), originalAlleleList.numberOfAlleles());
Assert.assertEquals(permutation.toSize(), targetAlleleList.numberOfAlleles());
for (int i = 0; i < permutation.fromSize(); i++) {
Assert.assertEquals(permutation.toIndex(i), targetAlleleList.indexOfAllele(originalAlleleList.getAllele(i)));
Assert.assertEquals(permutation.fromIndex(i), originalAlleleList.indexOfAllele(targetAlleleList.getAllele(i)));
Assert.assertEquals(permutation.fromIndex(i), fromIndex[i]);
}
Assert.assertTrue(AlleleList.equals(permutation, targetAlleleList));
}
use of htsjdk.variant.variantcontext.Allele in project gatk by broadinstitute.
the class ReadLikelihoodsUnitTest method testAlleleQueries.
private void testAlleleQueries(final AlleleList<Allele> alleles, ReadLikelihoods<Allele> result) {
final Set<Integer> alleleIndices = new LinkedHashSet<>();
for (final Allele allele : alleles.asListOfAlleles()) {
final int indexOfAllele = result.indexOfAllele(allele);
Assert.assertTrue(indexOfAllele >= 0);
Assert.assertFalse(alleleIndices.contains(indexOfAllele));
alleleIndices.add(indexOfAllele);
Assert.assertSame(allele, alleles.getAllele(indexOfAllele));
}
}
use of htsjdk.variant.variantcontext.Allele in project gatk by broadinstitute.
the class ReadLikelihoodsUnitTest method testAlleleQueries.
private void testAlleleQueries(Allele[] alleles, ReadLikelihoods<Allele> result) {
final Set<Integer> alleleIndices = new LinkedHashSet<>();
for (final Allele allele : alleles) {
final int indexOfAllele = result.indexOfAllele(allele);
Assert.assertTrue(indexOfAllele >= 0);
Assert.assertFalse(alleleIndices.contains(indexOfAllele));
alleleIndices.add(indexOfAllele);
Assert.assertSame(allele, alleles[indexOfAllele]);
}
}
Aggregations