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:
parent
98021db264
commit
b53336c2d0
|
|
@ -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.")
|
@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;
|
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
|
@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)
|
@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;
|
public PrintStream RECAL_TABLE_UPDATE_LOG = null;
|
||||||
|
|
|
||||||
|
|
@ -93,10 +93,13 @@ public class ReadGroupCovariate implements RequiredCovariate {
|
||||||
private final HashMap<String, Integer> readGroupLookupTable = new HashMap<String, Integer>();
|
private final HashMap<String, Integer> readGroupLookupTable = new HashMap<String, Integer>();
|
||||||
private final HashMap<Integer, String> readGroupReverseLookupTable = new HashMap<Integer, String>();
|
private final HashMap<Integer, String> readGroupReverseLookupTable = new HashMap<Integer, String>();
|
||||||
private int nextId = 0;
|
private int nextId = 0;
|
||||||
|
private String forceReadGroup;
|
||||||
|
|
||||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final RecalibrationArgumentCollection RAC) {}
|
public void initialize(final RecalibrationArgumentCollection RAC) {
|
||||||
|
forceReadGroup = RAC.FORCE_READGROUP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordValues(final GATKSAMRecord read, final ReadCovariates values) {
|
public void recordValues(final GATKSAMRecord read, final ReadCovariates values) {
|
||||||
|
|
@ -170,6 +173,9 @@ public class ReadGroupCovariate implements RequiredCovariate {
|
||||||
* @return platform unit or readgroup id
|
* @return platform unit or readgroup id
|
||||||
*/
|
*/
|
||||||
private String readGroupValueFromRG(final GATKSAMReadGroupRecord rg) {
|
private String readGroupValueFromRG(final GATKSAMReadGroupRecord rg) {
|
||||||
|
if ( forceReadGroup != null )
|
||||||
|
return forceReadGroup;
|
||||||
|
|
||||||
final String platformUnit = rg.getPlatformUnit();
|
final String platformUnit = rg.getPlatformUnit();
|
||||||
return platformUnit == null ? rg.getId() : platformUnit;
|
return platformUnit == null ? rg.getId() : platformUnit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,26 +75,37 @@ public class ReadGroupCovariateUnitTest {
|
||||||
final String expected = "SAMPLE.1";
|
final String expected = "SAMPLE.1";
|
||||||
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("MY.ID");
|
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("MY.ID");
|
||||||
rg.setPlatformUnit(expected);
|
rg.setPlatformUnit(expected);
|
||||||
runTest(rg, expected);
|
runTest(rg, expected, covariate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
public void testMissingPlatformUnit() {
|
public void testMissingPlatformUnit() {
|
||||||
final String expected = "MY.7";
|
final String expected = "MY.7";
|
||||||
GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(expected);
|
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);
|
GATKSAMRecord read = ReadUtils.createRandomRead(10);
|
||||||
read.setReadGroup(rg);
|
read.setReadGroup(rg);
|
||||||
ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
|
ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
|
||||||
covariate.recordValues(read, readCovariates);
|
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) {
|
for (int[] value : values) {
|
||||||
String actual = covariate.formatKey(value[0]);
|
String actual = covariate.formatKey(value[0]);
|
||||||
Assert.assertEquals(actual, expected);
|
Assert.assertEquals(actual, expected);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue