Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BQSR: avoid throwing an error when read group is missing in the recal table, and some refactoring. #9020

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
public class ApplyBQSRArgumentCollection extends ApplyBQSRUniqueArgumentCollection {
private static final long serialVersionUID = 1L;
public static final String USE_ORIGINAL_QUALITIES_LONG_NAME = "use-original-qualities";

/**
* This flag tells GATK not to modify quality scores less than this value. Instead they will be written out
Expand All @@ -26,6 +27,6 @@ public class ApplyBQSRArgumentCollection extends ApplyBQSRUniqueArgumentCollecti
* are stored in the OQ tag, if they are present, rather than use the post-recalibration quality scores. If no OQ
* tag is present for a read, the standard quality score will be used.
*/
@Argument(fullName="use-original-qualities", shortName = "OQ", doc = "Use the base quality scores from the OQ tag", optional = true)
@Argument(fullName=USE_ORIGINAL_QUALITIES_LONG_NAME, shortName = "OQ", doc = "Use the base quality scores from the OQ tag", optional = true)
public Boolean useOriginalBaseQualities = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
public class ApplyBQSRUniqueArgumentCollection implements Serializable {
private static final long serialVersionUID = 1L;

public static final String STATIC_QUANTIZED_QUALS_LONG_NAME = "static-quantized-quals";
public static final String ALLOW_MISSING_READ_GROUPS_LONG_NAME = "allow-missing-read-group";

/**
* Turns on the base quantization module. It requires a recalibration report.
*
Expand All @@ -31,9 +34,11 @@ public class ApplyBQSRUniqueArgumentCollection implements Serializable {
/**
* Static quantized quals are entirely separate from the quantize_qual option which uses dynamic binning.
* The two types of binning should not be used together.
*
* For example, the Warp germline pipeline uses the static bins { 10, 20, 30, 40 }
*/
@Advanced
@Argument(fullName="static-quantized-quals", doc = "Use static quantized quality scores to a given number of levels (with -"+ StandardArgumentDefinitions.BQSR_TABLE_SHORT_NAME+ ")", optional=true, mutex = "quantize-quals")
@Argument(fullName=STATIC_QUANTIZED_QUALS_LONG_NAME, doc = "Use static quantized quality scores to a given number of levels (with -"+ StandardArgumentDefinitions.BQSR_TABLE_SHORT_NAME+ ")", optional=true, mutex = "quantize-quals")
public List<Integer> staticQuantizationQuals = new ArrayList<>();

/**
Expand Down Expand Up @@ -61,6 +66,13 @@ public class ApplyBQSRUniqueArgumentCollection implements Serializable {
@Argument(fullName = "global-qscore-prior", doc = "Global Qscore Bayesian prior to use for BQSR", optional = true)
public double globalQScorePrior = -1.0;

/**
* If set to true, do not throw an error upon encountering a read with a read group that's not in the recalibration table.
* Instead, simply set the quantized original base qualities as the recalibrated base qualities.
*/
@Argument(fullName = ALLOW_MISSING_READ_GROUPS_LONG_NAME, doc = "Do not throw an error when encountering a read group not in the recal table", optional = true)
public boolean allowMissingReadGroups = false;

/**
* Combine the extra arguments in {@link ApplyBQSRArgumentCollection} that are not in this {@link ApplyBQSRUniqueArgumentCollection}
* from the given {@link RecalibrationArgumentCollection} to create a {@link ApplyBQSRArgumentCollection}.
Expand All @@ -75,6 +87,8 @@ public ApplyBQSRArgumentCollection toApplyBQSRArgumentCollection(RecalibrationAr
ret.roundDown = this.roundDown;
ret.emitOriginalQuals = this.emitOriginalQuals;
ret.globalQScorePrior = this.globalQScorePrior;
ret.allowMissingReadGroups = this.allowMissingReadGroups;

// include all the fields from RecalibrationArgumentCollection
ret.PRESERVE_QSCORES_LESS_THAN = bqsrArgs.PRESERVE_QSCORES_LESS_THAN;
ret.useOriginalBaseQualities = bqsrArgs.useOriginalBaseQualities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static RecalibrationReport apply(final JavaPairRDD<GATKRead, Iterable<GAT
RecalibrationTables::inPlaceCombine,
Math.max(1, (int)(Math.log(unmergedTables.partitions().size()) / Math.log(2))));

BaseRecalibrationEngine.finalizeRecalibrationTables(combinedTables);
BaseRecalibrationEngine.collapseQualityScoreTableToReadGroupTable(combinedTables.getQualityScoreTable(), combinedTables.getReadGroupTable());
BaseRecalibrationEngine.roundTableValues(combinedTables);

final QuantizationInfo quantizationInfo = new QuantizationInfo(combinedTables, recalArgs.QUANTIZING_LEVELS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public final class ApplyBQSR extends ReadWalker{

@Argument(fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, doc="Write output to this file")
@WorkflowOutput(optionalCompanions = {StandardArgumentDefinitions.OUTPUT_INDEX_COMPANION})
public GATKPath OUTPUT;
public GATKPath output;

/**
* This argument is required for recalibration of base qualities. The recalibration table is a file produced by
Expand All @@ -90,7 +90,7 @@ public final class ApplyBQSR extends ReadWalker{
*/
@Argument(fullName=StandardArgumentDefinitions.BQSR_TABLE_LONG_NAME, shortName=StandardArgumentDefinitions.BQSR_TABLE_SHORT_NAME, doc="Input recalibration table for BQSR")
@WorkflowInput
public File BQSR_RECAL_FILE;
public File bqsrRecalFile;

/**
* Command-line arguments to fine tune the recalibration.
Expand All @@ -105,12 +105,12 @@ public final class ApplyBQSR extends ReadWalker{
*/
@Override
public ReadTransformer makePostReadFilterTransformer(){
return new BQSRReadTransformer(getHeaderForReads(), BQSR_RECAL_FILE, bqsrArgs);
return new BQSRReadTransformer(getHeaderForReads(), bqsrRecalFile, bqsrArgs);
}

@Override
public void onTraversalStart() {
outputWriter = createSAMWriter(OUTPUT, true);
outputWriter = createSAMWriter(output, true);
Utils.warnOnNonIlluminaReadGroups(getHeaderForReads(), logger);
}

Expand Down
Loading
Loading