@Override public void addInfo(final AbstractLocusInfo<SamLocusIterator.RecordAndOffset> info, final ReferenceSequence ref, boolean referenceBaseN) { if (referenceBaseN) { return; } // Figure out the coverage while not counting overlapping reads twice, and excluding various things final HashSet<String> readNames = new HashSet<>(info.getRecordAndOffsets().size()); int pileupSize = 0; int unfilteredDepth = 0; for (final SamLocusIterator.RecordAndOffset recs : info.getRecordAndOffsets()) { if (recs.getBaseQuality() <= 2) { ++basesExcludedByBaseq; continue; } // we add to the base quality histogram any bases that have quality > 2 // the raw depth may exceed the coverageCap before the high-quality depth does. So stop counting once we reach the coverage cap. if (unfilteredDepth < coverageCap) { unfilteredBaseQHistogramArray[recs.getRecord().getBaseQualities()[recs.getOffset()]]++; unfilteredDepth++; } if (recs.getBaseQuality() < collectWgsMetrics.MINIMUM_BASE_QUALITY || SequenceUtil.isNoCall(recs.getReadBase())) { ++basesExcludedByBaseq; continue; } if (!readNames.add(recs.getRecord().getReadName())) { ++basesExcludedByOverlap; continue; } pileupSize++; } final int highQualityDepth = Math.min(pileupSize, coverageCap); if (highQualityDepth < pileupSize) basesExcludedByCapping += pileupSize - coverageCap; highQualityDepthHistogramArray[highQualityDepth]++; unfilteredDepthHistogramArray[unfilteredDepth]++; } }
@Override public void addInfo(final AbstractLocusInfo<SamLocusIterator.RecordAndOffset> info, final ReferenceSequence ref, boolean referenceBaseN) { if (referenceBaseN) { return; } // Figure out the coverage while not counting overlapping reads twice, and excluding various things final HashSet<String> readNames = new HashSet<>(info.getRecordAndOffsets().size()); int pileupSize = 0; int unfilteredDepth = 0; for (final SamLocusIterator.RecordAndOffset recs : info.getRecordAndOffsets()) { if (recs.getBaseQuality() <= 2) { ++basesExcludedByBaseq; continue; } // we add to the base quality histogram any bases that have quality > 2 // the raw depth may exceed the coverageCap before the high-quality depth does. So stop counting once we reach the coverage cap. if (unfilteredDepth < coverageCap) { unfilteredBaseQHistogramArray[recs.getRecord().getBaseQualities()[recs.getOffset()]]++; unfilteredDepth++; } if (recs.getBaseQuality() < collectWgsMetrics.MINIMUM_BASE_QUALITY || SequenceUtil.isNoCall(recs.getReadBase())) { ++basesExcludedByBaseq; continue; } if (!readNames.add(recs.getRecord().getReadName())) { ++basesExcludedByOverlap; continue; } pileupSize++; } final int highQualityDepth = Math.min(pileupSize, coverageCap); if (highQualityDepth < pileupSize) basesExcludedByCapping += pileupSize - coverageCap; highQualityDepthHistogramArray[highQualityDepth]++; unfilteredDepthHistogramArray[unfilteredDepth]++; } }
Assert.assertEquals(li.getInsertedInRecord().get(0).getOffset(), expectedInsertionOffset); Assert.assertEquals(li.getInsertedInRecord().get(1).getOffset(), expectedInsertionOffset); } else { Assert.assertEquals(li.getInsertedInRecord().size(), 0); Assert.assertEquals(li.getDeletedInRecord().get(0).getOffset(), expectedReadOffsets[i]); Assert.assertEquals(li.getDeletedInRecord().get(1).getOffset(), expectedReadOffsets[i]); } else { Assert.assertEquals(li.size(), coverage); Assert.assertEquals(li.getRecordAndOffsets().get(0).getOffset(), expectedReadOffsets[i]); Assert.assertEquals(li.getRecordAndOffsets().get(1).getOffset(), expectedReadOffsets[i]);
Assert.assertEquals(li.getRecordAndOffsets().size(), expectedReadOffsets[i].length); for (int j = 0; j < expectedReadOffsets[i].length; ++j) { Assert.assertEquals(li.getRecordAndOffsets().get(j).getOffset(), expectedReadOffsets[i][j]); Assert.assertEquals(li.getDeletedInRecord().get(0).getOffset(), expectedDelOffset);
Assert.assertEquals(li.getRecordAndOffsets().size(), expectedReadOffsets[i].length); for (int j = 0; j < expectedReadOffsets[i].length; ++j) { Assert.assertEquals(li.getRecordAndOffsets().get(j).getOffset(), expectedReadOffsets[i][j]);
if (oqs != null) qual = oqs[rec.getOffset()]; else qual = rec.getBaseQuality(); } else {
if (oqs != null) qual = oqs[rec.getOffset()]; else qual = rec.getBaseQuality(); } else {
private static Integer stratifyHomopolymerLength(final RecordAndOffset recordAndOffset, final SAMLocusAndReference locusInfo) { final ReadDirection direction = ReadDirection.of(recordAndOffset.getRecord()); final byte readBases[] = recordAndOffset.getRecord().getReadBases(); if (SequenceUtil.isNoCall(locusInfo.getReferenceBase())) { return null; } int runLengthOffset = recordAndOffset.getOffset(); if (runLengthOffset < 0 || runLengthOffset >= recordAndOffset.getRecord().getReadLength()) { return null; } if (direction == ReadDirection.POSITIVE) { while (--runLengthOffset >= 0) { if (readBases[runLengthOffset] != readBases[recordAndOffset.getOffset() - 1]) { break; } } return recordAndOffset.getOffset() - runLengthOffset - 1; } else { while (++runLengthOffset < recordAndOffset.getRecord().getReadLength()) { if (readBases[runLengthOffset] != readBases[recordAndOffset.getOffset() + 1]) { break; } } return runLengthOffset - recordAndOffset.getOffset() - 1; } }
private static Integer stratifyHomopolymerLength(final RecordAndOffset recordAndOffset, final SAMLocusAndReference locusInfo) { final ReadDirection direction = ReadDirection.of(recordAndOffset.getRecord()); final byte readBases[] = recordAndOffset.getRecord().getReadBases(); if (SequenceUtil.isNoCall(locusInfo.getReferenceBase())) { return null; } int runLengthOffset = recordAndOffset.getOffset(); if (runLengthOffset < 0 || runLengthOffset >= recordAndOffset.getRecord().getReadLength()) { return null; } if (direction == ReadDirection.POSITIVE) { while (--runLengthOffset >= 0) { if (readBases[runLengthOffset] != readBases[recordAndOffset.getOffset() - 1]) { break; } } return recordAndOffset.getOffset() - runLengthOffset - 1; } else { while (++runLengthOffset < recordAndOffset.getRecord().getReadLength()) { if (readBases[runLengthOffset] != readBases[recordAndOffset.getOffset() + 1]) { break; } } return runLengthOffset - recordAndOffset.getOffset() - 1; } }
/** * Get the one-based cycle number of the base, taking the direction of the read into account */ private static int stratifyCycle(final RecordAndOffset recordAndOffset) { final SAMRecord rec = recordAndOffset.getRecord(); final int offset = recordAndOffset.getOffset(); // Get either the offset into the array or the distance from the end depending on whether the read is // on the negative strand. int retval = rec.getReadNegativeStrandFlag() ? (rec.getReadLength() - offset - 1) : offset; // add 1 to move to a one-based system retval += 1; return retval; }
/** * Get the one-based cycle number of the base, taking the direction of the read into account */ private static int stratifyCycle(final RecordAndOffset recordAndOffset) { final SAMRecord rec = recordAndOffset.getRecord(); final int offset = recordAndOffset.getOffset(); // Get either the offset into the array or the distance from the end depending on whether the read is // on the negative strand. int retval = rec.getReadNegativeStrandFlag() ? (rec.getReadLength() - offset - 1) : offset; // add 1 to move to a one-based system retval += 1; return retval; }
private static Character stratifyReadBase(final RecordAndOffset recordAndOffset, int offset) { final ReadDirection direction = ReadDirection.of(recordAndOffset.getRecord()); final int requestedOffset = recordAndOffset.getOffset() + offset * (direction == ReadDirection.POSITIVE ? 1 : -1); if (requestedOffset < 0 || requestedOffset >= recordAndOffset.getRecord().getReadLength()) { return null; } else { return stratifySequenceBase(recordAndOffset.getRecord().getReadBases()[requestedOffset], direction == ReadDirection.NEGATIVE); } }
private static Character stratifyReadBase(final RecordAndOffset recordAndOffset, int offset) { final ReadDirection direction = ReadDirection.of(recordAndOffset.getRecord()); final int requestedOffset = recordAndOffset.getOffset() + offset * (direction == ReadDirection.POSITIVE ? 1 : -1); if (requestedOffset < 0 || requestedOffset >= recordAndOffset.getRecord().getReadLength()) { return null; } else { return stratifySequenceBase(recordAndOffset.getRecord().getReadBases()[requestedOffset], direction == ReadDirection.NEGATIVE); } }