use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class ChromosomeCountsUnitTest method testVC.
@Test
public void testVC() throws Exception {
final VariantContext vc = makeVC();
final ReferenceContext referenceContext = null;
final InfoFieldAnnotation ann = new ChromosomeCounts();
final Map<String, Object> annotate = ann.annotate(referenceContext, vc, null);
//two hets
Assert.assertEquals(annotate.get(VCFConstants.ALLELE_NUMBER_KEY), 4);
Assert.assertEquals(annotate.get(VCFConstants.ALLELE_COUNT_KEY), 2);
Assert.assertEquals(annotate.get(VCFConstants.ALLELE_FREQUENCY_KEY), 0.5);
Assert.assertEquals(ann.getDescriptions(), Arrays.asList(ChromosomeCounts.descriptions));
Assert.assertEquals(ann.getKeyNames(), Arrays.asList(ChromosomeCounts.keyNames));
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class ClippingRankSumTestUnitTest method testClipping.
@Test
public void testClipping() {
final int[] refHardClips = { 10, 0 };
final int[] altHardClips = { 1, 2 };
final List<GATKRead> refReads = Arrays.stream(refHardClips).mapToObj(i -> makeRead(i)).collect(Collectors.toList());
final List<GATKRead> altReads = Arrays.stream(altHardClips).mapToObj(i -> makeRead(i)).collect(Collectors.toList());
final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods(SAMPLE_1, refReads, altReads, -100.0, -100.0, REF, ALT);
final ReferenceContext ref = null;
final VariantContext vc = makeVC(REF, ALT);
final InfoFieldAnnotation ann = new ClippingRankSumTest();
final MannWhitneyU mannWhitneyU = new MannWhitneyU();
final Map<String, Object> annotate = ann.annotate(ref, vc, likelihoods);
final double zScore = mannWhitneyU.test(new double[] { altHardClips[0], altHardClips[1] }, new double[] { refHardClips[0], refHardClips[1] }, MannWhitneyU.TestType.FIRST_DOMINATES).getZ();
final String zScoreStr = String.format("%.3f", zScore);
Assert.assertEquals(annotate.get(GATKVCFConstants.CLIPPING_RANK_SUM_KEY), zScoreStr);
Assert.assertEquals(ann.getDescriptions().size(), 1);
Assert.assertEquals(ann.getDescriptions().get(0).getID(), GATKVCFConstants.CLIPPING_RANK_SUM_KEY);
Assert.assertEquals(ann.getKeyNames().size(), 1);
Assert.assertEquals(ann.getKeyNames().get(0), GATKVCFConstants.CLIPPING_RANK_SUM_KEY);
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class CoverageUnitTest method testLikelihoodsEmpty.
@Test
public void testLikelihoodsEmpty() throws Exception {
final List<GATKRead> reads = new ArrayList<>();
final Map<String, List<GATKRead>> readsBySample = ImmutableMap.of("sample1", reads);
final org.broadinstitute.hellbender.utils.genotyper.SampleList sampleList = new IndexedSampleList(Arrays.asList("sample1"));
final AlleleList<Allele> alleleList = new IndexedAlleleList<>(Arrays.asList(Allele.NO_CALL));
final ReadLikelihoods<Allele> likelihoods = new ReadLikelihoods<>(sampleList, alleleList, readsBySample);
final VariantContext vc = makeVC();
final ReferenceContext referenceContext = null;
final Map<String, Object> annotate = new Coverage().annotate(referenceContext, vc, likelihoods);
Assert.assertTrue(annotate.isEmpty());
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class BaseQualityRankSumTestUnitTest method testBaseQualRawAnnotate.
@Test
public void testBaseQualRawAnnotate() {
final AS_RankSumTest ann = new AS_BaseQualityRankSumTest();
final String key1 = GATKVCFConstants.AS_RAW_BASE_QUAL_RANK_SUM_KEY;
final String key2 = GATKVCFConstants.AS_BASE_QUAL_RANK_SUM_KEY;
final int[] altBaseQuals = { 10, 20 };
final int[] refBaseQuals = { 50, 60 };
final List<GATKRead> refReads = Arrays.stream(refBaseQuals).mapToObj(i -> makeRead(i)).collect(Collectors.toList());
final List<GATKRead> altReads = Arrays.stream(altBaseQuals).mapToObj(i -> makeRead(i)).collect(Collectors.toList());
final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods(SAMPLE_1, refReads, altReads, -100.0, -100.0, REF, ALT);
final ReferenceContext ref = null;
final VariantContext vc = makeVC(REF, ALT);
final Map<String, Object> annotateRaw = ann.annotateRawData(ref, vc, likelihoods);
final Map<String, Object> annotateNonRaw = ann.annotate(ref, vc, likelihoods);
final String expectedAnnotation = refBaseQuals[0] + ",1," + refBaseQuals[1] + ",1" + AS_RankSumTest.PRINT_DELIM + altBaseQuals[0] + ",1," + altBaseQuals[1] + ",1";
Assert.assertEquals(annotateRaw.get(key1), expectedAnnotation);
Assert.assertEquals(annotateNonRaw.get(key1), expectedAnnotation);
Assert.assertEquals(ann.getDescriptions().size(), 1);
Assert.assertEquals(ann.getDescriptions().get(0).getID(), key1);
Assert.assertEquals(ann.getKeyNames().size(), 1);
Assert.assertEquals(ann.getKeyNames().get(0), key2);
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class DepthPerSampleHCUnitTest method testNoReads.
@Test
public void testNoReads() {
final Allele Aref = Allele.create("A", true);
final Allele C = Allele.create("C");
final List<Allele> AC = Arrays.asList(Aref, C);
final ReferenceContext rc = new ReferenceContext();
final GenotypeBuilder gb = new GenotypeBuilder("sample", AC).DP(10).AD(new int[] { 5, 5 });
final Genotype g = gb.make();
final List<GATKRead> reads = new ArrayList<>();
final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods("sample", reads, -100.0, Aref, C);
final VariantContext vc = new VariantContextBuilder("test", "20", 10, 10, AC).genotypes(Arrays.asList(g)).make();
new DepthPerSampleHC().annotate(rc, vc, g, gb, likelihoods);
Assert.assertEquals(gb.make().getDP(), 0);
}
Aggregations