/** * Update the recalibration statistics using the information in recalInfo * * @param recalInfo data structure holding information about the recalibration values for a single * read */ @Requires("recalInfo != null") public void updateDataForRead(final ReadRecalibrationInfo recalInfo) { final GATKSAMRecord read = recalInfo.getRead(); final ReadCovariates readCovariates = recalInfo.getCovariatesValues(); final RecalibrationTables tables = getUpdatableRecalibrationTables(); final NestedIntegerArray<RecalDatum> qualityScoreTable = tables.getQualityScoreTable(); for (int offset = 0; offset < read.getReadBases().length; offset++) { if (!recalInfo.skip(offset)) { for (final EventType eventType : EventType.values()) { final int[] keys = readCovariates.getKeySet(offset, eventType); final int eventIndex = eventType.ordinal(); final byte qual = recalInfo.getQual(eventType, offset); final double isError = recalInfo.getErrorFraction(eventType, offset); RecalUtils.incrementDatumOrPutIfNecessary( qualityScoreTable, qual, isError, keys[0], keys[1], eventIndex); for (int i = 2; i < covariates.length; i++) { if (keys[i] < 0) continue; RecalUtils.incrementDatumOrPutIfNecessary( tables.getTable(i), qual, isError, keys[0], keys[1], keys[i], eventIndex); } } } } }
private static void runTest( final GATKSAMReadGroupRecord rg, final String expected, final ReadGroupCovariate covariate) { GATKSAMRecord read = ReadUtils.createRandomRead(10); read.setReadGroup(rg); ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1); covariate.recordValues(read, readCovariates); verifyCovariateArray(readCovariates.getMismatchesKeySet(), expected, covariate); }
@Test(enabled = false) public void testCovariateGeneration() { final String RGID = "id"; final int length = 10; final RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection(); GATKSAMRecord read = ReadUtils.createRandomRead(length, false); GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(RGID); rg.setPlatform("illumina"); read.setReadGroup(rg); final byte[] mQuals = read.getBaseQualities(EventType.BASE_SUBSTITUTION); final byte[] iQuals = read.getBaseQualities(EventType.BASE_INSERTION); final byte[] dQuals = read.getBaseQualities(EventType.BASE_DELETION); ReadGroupCovariate rgCov = new ReadGroupCovariate(); QualityScoreCovariate qsCov = new QualityScoreCovariate(); ContextCovariate coCov = new ContextCovariate(); CycleCovariate cyCov = new CycleCovariate(); rgCov.initialize(RAC); qsCov.initialize(RAC); coCov.initialize(RAC); cyCov.initialize(RAC); Covariate[] requestedCovariates = new Covariate[4]; requestedCovariates[0] = rgCov; requestedCovariates[1] = qsCov; requestedCovariates[2] = coCov; requestedCovariates[3] = cyCov; ReadCovariates rc = RecalDataManager.computeCovariates(read, requestedCovariates); // check that the length is correct Assert.assertEquals(rc.getMismatchesKeySet().length, length); Assert.assertEquals(rc.getInsertionsKeySet().length, length); Assert.assertEquals(rc.getDeletionsKeySet().length, length); for (int i = 0; i < length; i++) { // check that read group is always the same Assert.assertEquals(rgCov.formatKey(rc.getMismatchesKeySet(i)[0]), RGID); Assert.assertEquals(rgCov.formatKey(rc.getInsertionsKeySet(i)[0]), RGID); Assert.assertEquals(rgCov.formatKey(rc.getDeletionsKeySet(i)[0]), RGID); // check quality score Assert.assertEquals(qsCov.formatKey(rc.getMismatchesKeySet(i)[1]), "" + mQuals[i]); Assert.assertEquals(qsCov.formatKey(rc.getInsertionsKeySet(i)[1]), "" + iQuals[i]); Assert.assertEquals(qsCov.formatKey(rc.getDeletionsKeySet(i)[1]), "" + dQuals[i]); // check context Assert.assertEquals( coCov.formatKey(rc.getMismatchesKeySet(i)[2]), ContextCovariateUnitTest.expectedContext(read, i, RAC.MISMATCHES_CONTEXT_SIZE)); Assert.assertEquals( coCov.formatKey(rc.getInsertionsKeySet(i)[2]), ContextCovariateUnitTest.expectedContext(read, i, RAC.INDELS_CONTEXT_SIZE)); Assert.assertEquals( coCov.formatKey(rc.getDeletionsKeySet(i)[2]), ContextCovariateUnitTest.expectedContext(read, i, RAC.INDELS_CONTEXT_SIZE)); // check cycle Assert.assertEquals(cyCov.formatKey(rc.getMismatchesKeySet(i)[3]), "" + (i + 1)); Assert.assertEquals(cyCov.formatKey(rc.getInsertionsKeySet(i)[3]), "" + (i + 1)); Assert.assertEquals(cyCov.formatKey(rc.getDeletionsKeySet(i)[3]), "" + (i + 1)); } }
@BeforeMethod public void initCache() { ReadCovariates.clearKeysCache(); }