Search in sources :

Example 1 with AS_RankSumTest

use of org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest in project gatk by broadinstitute.

the class ReadPosRankSumTestUnitTest method testReadPos_Raw.

@Test
public void testReadPos_Raw() {
    final AS_RankSumTest ann = new AS_ReadPosRankSumTest();
    final String key1 = GATKVCFConstants.AS_RAW_READ_POS_RANK_SUM_KEY;
    final String key2 = GATKVCFConstants.AS_READ_POS_RANK_SUM_KEY;
    final int[] startAlts = { 3, 4 };
    final int[] startRefs = { 1, 2 };
    final int readLength = 10;
    final List<GATKRead> refReads = Arrays.asList(makeRead(startRefs[0], 30), makeRead(startRefs[1], 30));
    final List<GATKRead> altReads = Arrays.asList(makeRead(startAlts[0], 30), makeRead(startAlts[1], 30));
    final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods(sample1, refReads, altReads, -100.0, -100.0, REF, ALT);
    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);
    final ReferenceContext ref = null;
    //middle of the read
    final long position = 5L;
    final VariantContext vc = makeVC(position);
    final Map<String, Object> annotateRaw = ann.annotateRawData(ref, vc, likelihoods);
    final Map<String, Object> annotateNonRaw = ann.annotate(ref, vc, likelihoods);
    final String expected = startAlts[0] + ",1," + startAlts[1] + ",1" + AS_RankSumTest.PRINT_DELIM + startRefs[0] + ",1," + startRefs[1] + ",1";
    Assert.assertEquals(annotateRaw.get(key1), expected);
    Assert.assertEquals(annotateNonRaw.get(key1), expected);
    //past middle
    final long positionEnd = 8L;
    final VariantContext vcEnd = makeVC(positionEnd);
    //Note: past the middle of the read we compute the position from the end.
    final Map<String, Object> annotateEndRaw = ann.annotateRawData(ref, vcEnd, likelihoods);
    final Map<String, Object> annotateEndNonRaw = ann.annotate(ref, vcEnd, likelihoods);
    final String refS = (startRefs[0] + readLength - positionEnd - 1) + ",1," + (startRefs[1] + readLength - positionEnd - 1) + ",1";
    final String altS = (positionEnd - startAlts[1]) + ",1," + (positionEnd - startAlts[0]) + ",1";
    Assert.assertEquals(annotateEndRaw.get(key1), refS + AS_RankSumTest.PRINT_DELIM + altS);
    Assert.assertEquals(annotateEndNonRaw.get(key1), refS + AS_RankSumTest.PRINT_DELIM + altS);
    //past middle
    final long positionPastEnd = 20L;
    final VariantContext vcPastEnd = makeVC(positionPastEnd);
    //Note: past the end of the read, there's nothing
    final Map<String, Object> annotatePastEndRaw = ann.annotateRawData(ref, vcPastEnd, likelihoods);
    final Map<String, Object> annotatePastEndNonRaw = ann.annotate(ref, vcPastEnd, likelihoods);
    Assert.assertTrue(annotatePastEndRaw.isEmpty());
    Assert.assertTrue(annotatePastEndNonRaw.isEmpty());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) AS_ReadPosRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_ReadPosRankSumTest) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest) AS_ReadPosRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_ReadPosRankSumTest)

Example 2 with AS_RankSumTest

use of org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest in project gatk by broadinstitute.

the class MappingQualityRankSumTestUnitTest method testAS_MQRaw.

@Test
public void testAS_MQRaw() {
    final AS_RankSumTest ann = new AS_MappingQualityRankSumTest();
    final String key1 = GATKVCFConstants.AS_RAW_MAP_QUAL_RANK_SUM_KEY;
    final String key2 = GATKVCFConstants.AS_MAP_QUAL_RANK_SUM_KEY;
    final int[] altMappingQualities = { 10, 20 };
    final int[] refMappingQualities = { 100, 110 };
    final List<GATKRead> refReads = Arrays.stream(refMappingQualities).mapToObj(i -> makeRead(i)).collect(Collectors.toList());
    final List<GATKRead> altReads = Arrays.stream(altMappingQualities).mapToObj(i -> makeRead(i)).collect(Collectors.toList());
    final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods(sample1, 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> annotate = ann.annotate(ref, vc, likelihoods);
    final String expected = refMappingQualities[0] + ",1," + refMappingQualities[1] + ",1" + AS_RankSumTest.PRINT_DELIM + altMappingQualities[0] + ",1," + altMappingQualities[1] + ",1";
    Assert.assertEquals(annotate.get(key1), expected);
    Assert.assertEquals(annotateRaw.get(key1), expected);
    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);
}
Also used : TextCigarCodec(htsjdk.samtools.TextCigarCodec) Cigar(htsjdk.samtools.Cigar) AS_MappingQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_MappingQualityRankSumTest) Arrays(java.util.Arrays) GATKVCFConstants(org.broadinstitute.hellbender.utils.variant.GATKVCFConstants) Test(org.testng.annotations.Test) htsjdk.variant.variantcontext(htsjdk.variant.variantcontext) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Collectors(java.util.stream.Collectors) ReadLikelihoods(org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest) List(java.util.List) ArtificialReadUtils(org.broadinstitute.hellbender.utils.read.ArtificialReadUtils) Assert(org.testng.Assert) Map(java.util.Map) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) MannWhitneyU(org.broadinstitute.hellbender.utils.MannWhitneyU) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest) AS_MappingQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_MappingQualityRankSumTest) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) AS_MappingQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_MappingQualityRankSumTest) Test(org.testng.annotations.Test) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest)

Example 3 with AS_RankSumTest

use of org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest 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);
}
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) AS_RankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest) AS_BaseQualityRankSumTest(org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_BaseQualityRankSumTest) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) 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)

Aggregations

ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)3 AS_RankSumTest (org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RankSumTest)3 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)3 Test (org.testng.annotations.Test)3 htsjdk.variant.variantcontext (htsjdk.variant.variantcontext)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 MannWhitneyU (org.broadinstitute.hellbender.utils.MannWhitneyU)2 GATKVCFConstants (org.broadinstitute.hellbender.utils.variant.GATKVCFConstants)2 Assert (org.testng.Assert)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Cigar (htsjdk.samtools.Cigar)1 TextCigarCodec (htsjdk.samtools.TextCigarCodec)1 Collections (java.util.Collections)1 AS_BaseQualityRankSumTest (org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_BaseQualityRankSumTest)1 AS_MappingQualityRankSumTest (org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_MappingQualityRankSumTest)1 AS_ReadPosRankSumTest (org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_ReadPosRankSumTest)1 org.broadinstitute.hellbender.utils.genotyper (org.broadinstitute.hellbender.utils.genotyper)1