Added hidden mode for BQSR to force all read groups to be the same one.

* Very useful for debugging sample-specific issues
 * This argument got lost in the transition from BQSR v1 to v2
 * Added unit test to cover this case
This commit is contained in:
Eric Banks 2013-05-06 14:57:01 -04:00
parent 98021db264
commit b53336c2d0
3 changed files with 27 additions and 6 deletions

View File

@ -219,6 +219,10 @@ public class RecalibrationArgumentCollection {
@Argument(fullName = "force_platform", shortName = "fP", required = false, doc = "If provided, the platform of EVERY read will be forced to be the provided String. Valid options are illumina, 454, and solid.")
public String FORCE_PLATFORM = null;
@Hidden
@Argument(fullName = "force_readgroup", shortName = "fRG", required = false, doc = "If provided, the read group of EVERY read will be forced to be the provided String.")
public String FORCE_READGROUP = null;
@Hidden
@Output(fullName = "recal_table_update_log", shortName = "recal_table_update_log", required = false, doc = "If provided, log all updates to the recalibration tables to the given file. For debugging/testing purposes only", defaultToStdout = false)
public PrintStream RECAL_TABLE_UPDATE_LOG = null;

View File

@ -93,10 +93,13 @@ public class ReadGroupCovariate implements RequiredCovariate {
private final HashMap<String, Integer> readGroupLookupTable = new HashMap<String, Integer>();
private final HashMap<Integer, String> readGroupReverseLookupTable = new HashMap<Integer, String>();
private int nextId = 0;
private String forceReadGroup;
// Initialize any member variables using the command-line arguments passed to the walkers
@Override
public void initialize(final RecalibrationArgumentCollection RAC) {}
public void initialize(final RecalibrationArgumentCollection RAC) {
forceReadGroup = RAC.FORCE_READGROUP;
}
@Override
public void recordValues(final GATKSAMRecord read, final ReadCovariates values) {
@ -170,6 +173,9 @@ public class ReadGroupCovariate implements RequiredCovariate {
* @return platform unit or readgroup id
*/
private String readGroupValueFromRG(final GATKSAMReadGroupRecord rg) {
if ( forceReadGroup != null )
return forceReadGroup;
final String platformUnit = rg.getPlatformUnit();
return platformUnit == null ? rg.getId() : platformUnit;
}

View File

@ -75,26 +75,37 @@ public class ReadGroupCovariateUnitTest {
final String expected = "SAMPLE.1";
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("MY.ID");
rg.setPlatformUnit(expected);
runTest(rg, expected);
runTest(rg, expected, covariate);
}
@Test(enabled = true)
public void testMissingPlatformUnit() {
final String expected = "MY.7";
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(expected);
runTest(rg, expected);
runTest(rg, expected, covariate);
}
private void runTest(GATKSAMReadGroupRecord rg, String expected) {
@Test(enabled = true)
public void testForceReadgroup() {
final RecalibrationArgumentCollection forcedRAC = new RecalibrationArgumentCollection();
forcedRAC.FORCE_READGROUP = "FOO";
final ReadGroupCovariate forcedCovariate = new ReadGroupCovariate();
forcedCovariate.initialize(forcedRAC);
final GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("NOT_FOO");
runTest(rg, "FOO", forcedCovariate);
}
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);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), expected, covariate);
}
private void verifyCovariateArray(int[][] values, String expected) {
private static void verifyCovariateArray(final int[][] values, final String expected, final ReadGroupCovariate covariate) {
for (int[] value : values) {
String actual = covariate.formatKey(value[0]);
Assert.assertEquals(actual, expected);