use of org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods in project gatk by broadinstitute.
the class MappingQualityZeroUnitTest method testEmptyLikelihoods.
@Test
public void testEmptyLikelihoods() throws Exception {
final List<GATKRead> reads = Collections.emptyList();
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.create("A")));
final ReadLikelihoods<Allele> likelihoods = new ReadLikelihoods<>(sampleList, alleleList, readsBySample);
final VariantContext vc = makeVC();
final ReferenceContext referenceContext = null;
final Map<String, Object> annotate = new MappingQualityZero().annotate(referenceContext, vc, likelihoods);
//strangely, MappingQualityZero returns 0 if likelihoods is empty
final int n = 0;
Assert.assertEquals(annotate.get(VCFConstants.MAPPING_QUALITY_ZERO_KEY), String.valueOf(n));
}
use of org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods 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.utils.genotyper.ReadLikelihoods 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.utils.genotyper.ReadLikelihoods in project gatk-protected by broadinstitute.
the class AssemblyBasedCallerUtils method realignReadsToTheirBestHaplotype.
/**
* Returns a map with the original read as a key and the realigned read as the value.
* <p>
* Missing keys or equivalent key and value pairs mean that the read was not realigned.
* </p>
* @return never {@code null}
*/
public static Map<GATKRead, GATKRead> realignReadsToTheirBestHaplotype(final ReadLikelihoods<Haplotype> originalReadLikelihoods, final Haplotype refHaplotype, final Locatable paddedReferenceLoc) {
final Collection<ReadLikelihoods<Haplotype>.BestAllele<Haplotype>> bestAlleles = originalReadLikelihoods.bestAlleles();
final Map<GATKRead, GATKRead> result = new HashMap<>(bestAlleles.size());
for (final ReadLikelihoods<Haplotype>.BestAllele<Haplotype> bestAllele : bestAlleles) {
final GATKRead originalRead = bestAllele.read;
final Haplotype bestHaplotype = bestAllele.allele;
final boolean isInformative = bestAllele.isInformative();
final GATKRead realignedRead = AlignmentUtils.createReadAlignedToRef(originalRead, bestHaplotype, refHaplotype, paddedReferenceLoc.getStart(), isInformative);
result.put(originalRead, realignedRead);
}
return result;
}
use of org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods in project gatk by broadinstitute.
the class CoverageUnitTest method testLikelihoods.
@Test
public void testLikelihoods() {
final Allele REF = Allele.create("T", true);
final Allele ALT = Allele.create("A");
final int refDepth = 5;
final int altDepth = 3;
final List<GATKRead> refReads = IntStream.range(0, refDepth).mapToObj(n -> makeRead()).collect(Collectors.toList());
final List<GATKRead> altReads = IntStream.range(0, altDepth).mapToObj(n -> makeRead()).collect(Collectors.toList());
final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods("sample1", refReads, altReads, -100.0, -100.0, REF, ALT);
final VariantContext vc = makeVC();
final ReferenceContext referenceContext = null;
final Map<String, Object> annotate = new Coverage().annotate(referenceContext, vc, likelihoods);
Assert.assertEquals(annotate.size(), 1, "size");
Assert.assertEquals(annotate.keySet(), Collections.singleton(VCFConstants.DEPTH_KEY), "annots");
final int m = altDepth + refDepth;
Assert.assertEquals(annotate.get(VCFConstants.DEPTH_KEY), String.valueOf(m));
}
Aggregations