Search in sources :

Example 26 with ReferenceContext

use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.

the class CoverageUnitTest method testAllNull.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testAllNull() throws Exception {
    final VariantContext vc = null;
    final ReferenceContext referenceContext = null;
    final InfoFieldAnnotation cov = new Coverage();
    //vc can't be null
    final Map<String, Object> annotate = cov.annotate(referenceContext, vc, null);
}
Also used : ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) VariantContext(htsjdk.variant.variantcontext.VariantContext) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 27 with ReferenceContext

use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.

the class BaseQualityRankSumTestUnitTest method testBaseQual.

@Test
public void testBaseQual() {
    final InfoFieldAnnotation ann = new BaseQualityRankSumTest();
    final String key = GATKVCFConstants.BASE_QUAL_RANK_SUM_KEY;
    final MannWhitneyU mannWhitneyU = new MannWhitneyU();
    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> annotate = ann.annotate(ref, vc, likelihoods);
    final double zScore = mannWhitneyU.test(new double[] { altBaseQuals[0], altBaseQuals[1] }, new double[] { refBaseQuals[0], refBaseQuals[1] }, MannWhitneyU.TestType.FIRST_DOMINATES).getZ();
    final String zScoreStr = String.format("%.3f", zScore);
    Assert.assertEquals(annotate.get(key), zScoreStr);
    Assert.assertEquals(ann.getDescriptions().size(), 1);
    Assert.assertEquals(ann.getDescriptions().get(0).getID(), key);
    Assert.assertEquals(ann.getKeyNames().size(), 1);
    Assert.assertEquals(ann.getKeyNames().get(0), key);
}
Also used : AS_BaseQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_BaseQualityRankSumTest) Arrays(java.util.Arrays) ImmutableMap(com.google.common.collect.ImmutableMap) GATKVCFConstants(org.broadinstitute.hellbender.utils.variant.GATKVCFConstants) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) Test(org.testng.annotations.Test) htsjdk.variant.variantcontext(htsjdk.variant.variantcontext) Mockito.when(org.mockito.Mockito.when) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Collectors(java.util.stream.Collectors) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest) List(java.util.List) Assert(org.testng.Assert) Map(java.util.Map) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) MannWhitneyU(org.broadinstitute.hellbender.utils.MannWhitneyU) Collections(java.util.Collections) org.broadinstitute.hellbender.utils.genotyper(org.broadinstitute.hellbender.utils.genotyper) Mockito.mock(org.mockito.Mockito.mock) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) AS_BaseQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_BaseQualityRankSumTest) MannWhitneyU(org.broadinstitute.hellbender.utils.MannWhitneyU) AS_BaseQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_BaseQualityRankSumTest) Test(org.testng.annotations.Test) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest)

Example 28 with ReferenceContext

use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.

the class RMSMappingQualityUnitTest method testNullLikelihoods.

@Test
public void testNullLikelihoods() throws Exception {
    final VariantContext vc = makeVC();
    final ReferenceContext referenceContext = null;
    final InfoFieldAnnotation cov = new RMSMappingQuality();
    final Map<String, Object> annotate = cov.annotate(referenceContext, vc, null);
    Assert.assertTrue(annotate.isEmpty());
    Assert.assertEquals(cov.getDescriptions().get(0).getID(), VCFConstants.RMS_MAPPING_QUALITY_KEY);
    Assert.assertEquals(cov.getDescriptions().get(1).getID(), GATKVCFConstants.RAW_RMS_MAPPING_QUALITY_KEY);
    Assert.assertEquals(cov.getDescriptions().get(0).getID(), VCFConstants.RMS_MAPPING_QUALITY_KEY);
}
Also used : ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) AS_RMSMappingQuality(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RMSMappingQuality) Test(org.testng.annotations.Test)

Example 29 with ReferenceContext

use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.

the class RMSMappingQualityUnitTest method testNullLikelihoods_AS.

@Test
public void testNullLikelihoods_AS() throws Exception {
    final VariantContext vc = makeVC();
    final ReferenceContext referenceContext = null;
    final InfoFieldAnnotation cov = new AS_RMSMappingQuality();
    final Map<String, Object> annotate = cov.annotate(referenceContext, vc, null);
    Assert.assertTrue(annotate.isEmpty());
    Assert.assertEquals(cov.getDescriptions().size(), 1);
    Assert.assertEquals(cov.getDescriptions().get(0).getID(), GATKVCFConstants.AS_RAW_RMS_MAPPING_QUALITY_KEY);
}
Also used : AS_RMSMappingQuality(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RMSMappingQuality) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) Test(org.testng.annotations.Test)

Example 30 with ReferenceContext

use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.

the class MappingQualityZeroUnitTest method testNullLikelihoods.

@Test
public void testNullLikelihoods() throws Exception {
    final VariantContext vc = makeVC();
    final ReferenceContext referenceContext = null;
    final InfoFieldAnnotation cov = new MappingQualityZero();
    final Map<String, Object> annotate = cov.annotate(referenceContext, vc, null);
    Assert.assertTrue(annotate.isEmpty());
    Assert.assertEquals(cov.getDescriptions().size(), 1);
    Assert.assertEquals(cov.getDescriptions().get(0).getID(), VCFConstants.MAPPING_QUALITY_ZERO_KEY);
}
Also used : ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) VariantContext(htsjdk.variant.variantcontext.VariantContext) Test(org.testng.annotations.Test)

Aggregations

ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)41 Test (org.testng.annotations.Test)30 VariantContext (htsjdk.variant.variantcontext.VariantContext)17 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)17 ReadLikelihoods (org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods)15 Collectors (java.util.stream.Collectors)13 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)12 Allele (htsjdk.variant.variantcontext.Allele)10 GATKVCFConstants (org.broadinstitute.hellbender.utils.variant.GATKVCFConstants)10 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)9 htsjdk.variant.variantcontext (htsjdk.variant.variantcontext)8 java.util (java.util)8 List (java.util.List)8 AS_RMSMappingQuality (org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RMSMappingQuality)8 Assert (org.testng.Assert)8 VCFConstants (htsjdk.variant.vcf.VCFConstants)7 Map (java.util.Map)7 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)7 ImmutableMap (com.google.common.collect.ImmutableMap)6 MannWhitneyU (org.broadinstitute.hellbender.utils.MannWhitneyU)6