Skip to content

Commit

Permalink
Added a check to ensure previous caching information doesn't affect r…
Browse files Browse the repository at this point in the history
…eferenceConfidenceCalls (#5911)

* Added a defensive check to calculateReferenceConfidence() to ensure the Indel cache has been cleared from underlying reads

* Added a proper test of cache clearing behavior

Resolves #5908
  • Loading branch information
jamesemery authored and droazen committed May 21, 2019
1 parent 5a5c38e commit 497fef2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ public List<VariantContext> calculateRefConfidence(final Haplotype refHaplotype,
}
}

// Ensuring that we remove any indel informativeness data we may have attached to the underlying reads for caching purposes
// This is important as if multiple reference blocks are computed for a low complexity active region some reads may incorrectly
// be using caching values computed for a different reference block.
if (USE_CACHED_READ_INDEL_INFORMATIVENESS_VALUES) {
readLikelihoods.sampleReads(0).forEach(r -> r.clearTransientAttribute(INDEL_INFORMATIVE_BASES_CACHE_ATTRIBUTE_NAME));
}

return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ public void testRefConfidenceBasic(final int nReads, final int extension) {
final IndependentSampleGenotypesModel genotypingModel = new IndependentSampleGenotypesModel();
final List<Integer> expectedDPs = Collections.nCopies(data.getActiveRegion().getSpan().size(), nReads);
final List<VariantContext> contexts = model.calculateRefConfidence(data.getRefHap(), haplotypes, data.getPaddedRefLoc(), data.getActiveRegion(), likelihoods, ploidyModel, calls, false, Collections.emptyList());
// Asserting that none of the reads after calculateRefConfidence have indel informativeness caching values attached.
for (GATKRead read : data.getActiveRegion().getReads()) {
Assert.assertNull(read.getTransientAttribute(ReferenceConfidenceModel.INDEL_INFORMATIVE_BASES_CACHE_ATTRIBUTE_NAME));
}
checkReferenceModelResult(data, contexts, expectedDPs, calls);
}

Expand All @@ -529,6 +533,10 @@ public void testRefConfidencePartialReads() {
final List<Integer> expectedDPs = new ArrayList<>(Collections.nCopies(data.getActiveRegion().getSpan().size(), 0));
for ( int i = start; i < readLen + start; i++ ) expectedDPs.set(i, 1);
final List<VariantContext> contexts = model.calculateRefConfidence(data.getRefHap(), haplotypes, data.getPaddedRefLoc(), data.getActiveRegion(), likelihoods, ploidyModel, calls);
// Asserting that none of the reads after calculateRefConfidence have indel informativeness caching values attached.
for (GATKRead read : data.getActiveRegion().getReads()) {
Assert.assertNull(read.getTransientAttribute(ReferenceConfidenceModel.INDEL_INFORMATIVE_BASES_CACHE_ATTRIBUTE_NAME));
}
checkReferenceModelResult(data, contexts, expectedDPs, calls);
}
}
Expand Down Expand Up @@ -565,6 +573,10 @@ public void testRefConfidenceWithCalls() {

final List<Integer> expectedDPs = Collections.nCopies(data.getActiveRegion().getSpan().size(), nReads);
final List<VariantContext> contexts = model.calculateRefConfidence(data.getRefHap(), haplotypes, data.getPaddedRefLoc(), data.getActiveRegion(), likelihoods, ploidyModel, calls);
// Asserting that none of the reads after calculateRefConfidence have indel informativeness caching values attached.
for (GATKRead read : data.getActiveRegion().getReads()) {
Assert.assertNull(read.getTransientAttribute(ReferenceConfidenceModel.INDEL_INFORMATIVE_BASES_CACHE_ATTRIBUTE_NAME));
}
checkReferenceModelResult(data, contexts, expectedDPs, calls);
}
}
Expand Down

0 comments on commit 497fef2

Please sign in to comment.