Enabling the Recal Report unit test (which looks like it was never ever enabled)
This commit is contained in:
parent
efceb0d48c
commit
75d5b88a3d
|
|
@ -69,12 +69,12 @@ public class RecalibrationReport {
|
|||
|
||||
}
|
||||
|
||||
protected RecalibrationReport(final QuantizationInfo quantizationInfo, final RecalibrationTables recalibrationTables, final GATKReportTable argumentTable, final RecalibrationArgumentCollection RAC) {
|
||||
protected RecalibrationReport(final QuantizationInfo quantizationInfo, final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates, final GATKReportTable argumentTable, final RecalibrationArgumentCollection RAC) {
|
||||
this.quantizationInfo = quantizationInfo;
|
||||
this.recalibrationTables = recalibrationTables;
|
||||
this.requestedCovariates = requestedCovariates;
|
||||
this.argumentTable = argumentTable;
|
||||
this.RAC = RAC;
|
||||
this.requestedCovariates = null;
|
||||
this.optionalCovariateIndexes = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import java.util.EnumSet;
|
|||
public class CycleCovariate implements StandardCovariate {
|
||||
|
||||
private int MAXIMUM_CYCLE_VALUE;
|
||||
private static final int CUSHION_FOR_INDELS = 4;
|
||||
public static final int CUSHION_FOR_INDELS = 4;
|
||||
private String default_platform = null;
|
||||
|
||||
private static final EnumSet<NGSPlatform> DISCRETE_CYCLE_PLATFORMS = EnumSet.of(NGSPlatform.ILLUMINA, NGSPlatform.SOLID, NGSPlatform.PACBIO, NGSPlatform.COMPLETE_GENOMICS);
|
||||
|
|
|
|||
|
|
@ -4,16 +4,12 @@ import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollectio
|
|||
import org.broadinstitute.sting.utils.recalibration.covariates.*;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.collections.NestedIntegerArray;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMReadGroupRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.sam.ReadUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +25,7 @@ public class RecalibrationReportUnitTest {
|
|||
return new RecalDatum(nObservations, nErrors, (byte)qual);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
@Test(enabled = true)
|
||||
public void testOutput() {
|
||||
final int length = 100;
|
||||
|
||||
|
|
@ -79,7 +75,7 @@ public class RecalibrationReportUnitTest {
|
|||
readQuals[i] = 20;
|
||||
read.setBaseQualities(readQuals);
|
||||
|
||||
final int expectedKeys = expectedNumberOfKeys(4, length, RAC.INDELS_CONTEXT_SIZE, RAC.MISMATCHES_CONTEXT_SIZE);
|
||||
final int expectedKeys = expectedNumberOfKeys(length, RAC.INDELS_CONTEXT_SIZE, RAC.MISMATCHES_CONTEXT_SIZE);
|
||||
int nKeys = 0; // keep track of how many keys were produced
|
||||
final ReadCovariates rc = RecalUtils.computeCovariates(read, requestedCovariates);
|
||||
|
||||
|
|
@ -99,35 +95,25 @@ public class RecalibrationReportUnitTest {
|
|||
nKeys += 2;
|
||||
for (int j = 0; j < optionalCovariates.size(); j++) {
|
||||
final NestedIntegerArray<RecalDatum> covTable = recalibrationTables.getTable(RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j);
|
||||
covTable.put(createRandomRecalDatum(randomMax, 10), covariates[0], covariates[1], j, covariates[RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j], errorMode.index);
|
||||
nKeys++;
|
||||
final int covValue = covariates[RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j];
|
||||
if ( covValue >= 0 ) {
|
||||
covTable.put(createRandomRecalDatum(randomMax, 10), covariates[0], covariates[1], covValue, errorMode.index);
|
||||
nKeys++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(nKeys, expectedKeys);
|
||||
|
||||
final RecalibrationReport report = new RecalibrationReport(quantizationInfo, recalibrationTables, RAC.generateReportTable("ignore"), RAC);
|
||||
|
||||
File output = new File("RecalibrationReportUnitTestOutuput.grp");
|
||||
PrintStream out;
|
||||
try {
|
||||
out = new PrintStream(output);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new ReviewedStingException("couldn't create the file " + output, e);
|
||||
}
|
||||
report.output(out);
|
||||
|
||||
RecalibrationReport loadedReport = new RecalibrationReport(output);
|
||||
|
||||
Assert.assertTrue(report.equals(loadedReport));
|
||||
if (!output.delete())
|
||||
throw new ReviewedStingException("File could not be deleted " + output);
|
||||
}
|
||||
|
||||
private static int expectedNumberOfKeys (int nCovariates, int readLength, int indelContextSize, int mismatchesContextSize) {
|
||||
int nommcs = readLength >= mismatchesContextSize ? mismatchesContextSize-1 : readLength;
|
||||
int noincs = readLength >= indelContextSize ? 2*(indelContextSize-1) : 2*readLength;
|
||||
return (nCovariates * readLength * 3) - nommcs - noincs;
|
||||
private static int expectedNumberOfKeys (int readLength, int indelContextSize, int mismatchesContextSize) {
|
||||
final int numCovariates = 4;
|
||||
final int numTables = 3;
|
||||
final int mismatchContextPadding = mismatchesContextSize - 1;
|
||||
final int indelContextPadding = 2 * (indelContextSize - 1);
|
||||
final int indelCyclePadding = 2 * (2 * CycleCovariate.CUSHION_FOR_INDELS);
|
||||
|
||||
return (numCovariates * numTables * readLength) - mismatchContextPadding - indelContextPadding - indelCyclePadding;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue