/** * @return true if all the tables contain no RecalDatums */ public boolean isEmpty() { for( final NestedIntegerArray<RecalDatum> table : tables ) { if( !table.getAllValues().isEmpty() ) { return false; } } return true; }
public QuantizationInfo(final RecalibrationTables recalibrationTables, final int quantizationLevels) { final Long [] qualHistogram = new Long[QualityUtils.MAX_SAM_QUAL_SCORE +1]; // create a histogram with the empirical quality distribution for (int i = 0; i < qualHistogram.length; i++) qualHistogram[i] = 0L; final NestedIntegerArray<RecalDatum> qualTable = recalibrationTables.getQualityScoreTable(); // get the quality score table for (final RecalDatum value : qualTable.getAllValues()) { final RecalDatum datum = value; final int empiricalQual = MathUtils.fastRound(datum.getEmpiricalQuality()); // convert the empirical quality to an integer ( it is already capped by MAX_QUAL ) qualHistogram[empiricalQual] += (long) datum.getNumObservations(); // add the number of observations for every key } empiricalQualCounts = Arrays.asList(qualHistogram); // histogram with the number of observations of the empirical qualities quantizeQualityScores(quantizationLevels); this.quantizationLevels = quantizationLevels; }
@Test public void basicMakeQualityScoreTable() { final Covariate qualCov = covariates[1]; final NestedIntegerArray<RecalDatum> copy = tables.makeQualityScoreTable(); testDimensions(copy, numReadGroups, qualCov.maximumKeyValue()+1); Assert.assertEquals(copy.getAllValues().size(), 0); }
@Test(dataProvider = "CombineTablesProvider") public void testCombineTables(final List<Row> table1, final List<Row> table2) { final NestedIntegerArray<RecalDatum> nia1 = makeTable(table1); final NestedIntegerArray<RecalDatum> nia2 = makeTable(table2); final List<Row> expectedRows = makeExpected(table1, table2); final NestedIntegerArray<RecalDatum> expected = makeTable(expectedRows); RecalUtils.combineTables(nia1, nia2); Assert.assertEquals(nia1.getDimensions(), expected.getDimensions()); Assert.assertEquals(nia1.getAllValues().size(), expected.getAllValues().size()); for ( final NestedIntegerArray.Leaf<RecalDatum> leaf : expected.getAllLeaves() ) { final RecalDatum actual = nia1.get(leaf.keys); Assert.assertEquals(actual.getNumMismatches(), leaf.value.getNumMismatches()); Assert.assertEquals(actual.getNumObservations(), leaf.value.getNumObservations()); } }