use of org.broadinstitute.hellbender.transformers.ReadTransformer in project gatk by broadinstitute.
the class BaseRecalibrationEngine method processRead.
/**
* For each read at this locus get the various covariate values and increment that location in the map based on
* whether or not the base matches the reference at this particular location
*/
public void processRead(final GATKRead originalRead, final ReferenceDataSource refDS, final Iterable<? extends Locatable> knownSites) {
final ReadTransformer transform = makeReadTransform();
final GATKRead read = transform.apply(originalRead);
if (read.isEmpty()) {
// the whole read was inside the adaptor so skip it
return;
}
RecalUtils.parsePlatformForRead(read, readsHeader, recalArgs);
int[] isSNP = new int[read.getLength()];
int[] isInsertion = new int[isSNP.length];
int[] isDeletion = new int[isSNP.length];
//Note: this function modifies the isSNP, isInsertion and isDeletion arguments so it can't be skipped, BAQ or no BAQ
final int nErrors = calculateIsSNPOrIndel(read, refDS, isSNP, isInsertion, isDeletion);
// note for efficiency reasons we don't compute the BAQ array unless we actually have
// some error to marginalize over. For ILMN data ~85% of reads have no error
final byte[] baqArray = (nErrors == 0 || !recalArgs.enableBAQ) ? flatBAQArray(read) : calculateBAQArray(read, refDS);
if (baqArray != null) {
// some reads just can't be BAQ'ed
final ReadCovariates covariates = RecalUtils.computeCovariates(read, readsHeader, this.covariates, true, keyCache);
// skip known sites of variation as well as low quality and non-regular bases
final boolean[] skip = calculateSkipArray(read, knownSites);
final double[] snpErrors = calculateFractionalErrorArray(isSNP, baqArray);
final double[] insertionErrors = calculateFractionalErrorArray(isInsertion, baqArray);
final double[] deletionErrors = calculateFractionalErrorArray(isDeletion, baqArray);
// aggregate all of the info into our info object, and update the data
final ReadRecalibrationInfo info = new ReadRecalibrationInfo(read, covariates, skip, snpErrors, insertionErrors, deletionErrors);
updateRecalTablesForRead(info);
}
numReadsProcessed++;
}
use of org.broadinstitute.hellbender.transformers.ReadTransformer in project gatk by broadinstitute.
the class ReadTransformerTest method testCompose.
@Test(dataProvider = "UnmodifiedReadDataProvider")
public void testCompose(final GATKRead read) {
ReadTransformer leftThen20 = moveLeft.compose(moveTo20);
leftThen20.apply(read);
Assert.assertEquals(read.getStart(), 19);
moveTo20.compose(moveLeft).apply(read);
Assert.assertEquals(read.getStart(), 20);
}
use of org.broadinstitute.hellbender.transformers.ReadTransformer in project gatk by broadinstitute.
the class GATKTool method getTransformedReadStream.
/**
* Returns a stream over the reads, which are:
*
* 1. Transformed with {@link #makePreReadFilterTransformer()}.
* 2. Filtered with {@code filter}.
* 3. Transformed with {@link #makePostReadFilterTransformer()}.
*
* Note: the filter is passed to keep the state of {@link CountingReadFilter}, obtained with {@link #makeReadFilter()}.
*/
protected Stream<GATKRead> getTransformedReadStream(final ReadFilter filter) {
// if has reads, return an transformed/filtered/transformed stream
if (hasReads()) {
final ReadTransformer preTransformer = makePreReadFilterTransformer();
final ReadTransformer postTransformer = makePostReadFilterTransformer();
return Utils.stream(reads).map(preTransformer).filter(filter).map(postTransformer);
}
// returns an empty Stream if there are no reads
return Stream.empty();
}
use of org.broadinstitute.hellbender.transformers.ReadTransformer in project gatk by broadinstitute.
the class BaseRecalibrationEngine method makeReadTransform.
private ReadTransformer makeReadTransform() {
ReadTransformer f0 = BaseRecalibrationEngine::consolidateCigar;
ReadTransformer f = f0.andThen(this::setDefaultBaseQualities).andThen(this::resetOriginalBaseQualities).andThen(ReadClipper::hardClipAdaptorSequence).andThen(ReadClipper::hardClipSoftClippedBases);
return f;
}
use of org.broadinstitute.hellbender.transformers.ReadTransformer in project gatk by broadinstitute.
the class ReadTransformerTest method testAndThen.
@Test(dataProvider = "UnmodifiedReadDataProvider")
public void testAndThen(final GATKRead read) {
ReadTransformer leftThen20 = moveLeft.andThen(moveTo20);
leftThen20.apply(read);
Assert.assertEquals(read.getStart(), 20);
moveTo20.andThen(moveLeft).apply(read);
Assert.assertEquals(read.getStart(), 19);
}
Aggregations