From daeb55429e68624c12053e99ae635c216f362f89 Mon Sep 17 00:00:00 2001 From: Mark Fleharty Date: Fri, 10 Jul 2015 23:46:36 -0400 Subject: [PATCH] Adding Static Binning to BQSR --- .../recalibration/BQSRReadTransformer.java | 2 +- .../recalibration/BaseRecalibration.java | 85 ++++++++++++- .../BaseRecalibrationUnitTest.java | 116 ++++++++++++++++++ .../walkers/bqsr/BQSRIntegrationTest.java | 37 +++++- .../arguments/GATKArgumentCollection.java | 19 +++ .../engine/recalibration/BQSRArgumentSet.java | 15 +++ 6 files changed, 270 insertions(+), 4 deletions(-) create mode 100644 protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibrationUnitTest.java diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRReadTransformer.java b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRReadTransformer.java index 4c8e1b16c..9446b578e 100644 --- a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRReadTransformer.java +++ b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRReadTransformer.java @@ -82,7 +82,7 @@ public class BQSRReadTransformer extends ReadTransformer { // Although we could add this check to the apply() method below, it's kind of ugly and inefficient. // The call here would be: RecalUtils.checkForInvalidRecalBams(engine.getSAMFileHeaders(), engine.getArguments().ALLOW_BQSR_ON_REDUCED_BAMS); final BQSRArgumentSet args = engine.getBQSRArgumentSet(); - this.bqsr = new BaseRecalibration(args.getRecalFile(), args.getQuantizationLevels(), args.shouldDisableIndelQuals(), args.getPreserveQscoresLessThan(), args.shouldEmitOriginalQuals(), args.getGlobalQScorePrior()); + this.bqsr = new BaseRecalibration(args.getRecalFile(), args.getQuantizationLevels(), args.shouldDisableIndelQuals(), args.getPreserveQscoresLessThan(), args.shouldEmitOriginalQuals(), args.getGlobalQScorePrior(), args.getStaticQuantizedQuals(), args.getRoundDown()); } final BQSRMode mode = WalkerManager.getWalkerAnnotation(walker, BQSRMode.class); return mode.ApplicationTime(); diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibration.java b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibration.java index 3e0a27adb..53fb9c127 100644 --- a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibration.java +++ b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibration.java @@ -62,6 +62,8 @@ import org.broadinstitute.gatk.utils.recalibration.EventType; import org.broadinstitute.gatk.engine.recalibration.covariates.Covariate; import org.broadinstitute.gatk.utils.sam.GATKSAMRecord; +import java.util.Collections; +import java.util.Iterator; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -86,6 +88,8 @@ public class BaseRecalibration { private final double globalQScorePrior; private final boolean emitOriginalQuals; + private byte[] staticQuantizedMapping = null; + /** * Constructor using a GATK Report file * @@ -93,8 +97,9 @@ public class BaseRecalibration { * @param quantizationLevels number of bins to quantize the quality scores * @param disableIndelQuals if true, do not emit base indel qualities * @param preserveQLessThan preserve quality scores less than this value + * @param staticQuantizedQuals static quantized bins for quality scores */ - public BaseRecalibration(final File RECAL_FILE, final int quantizationLevels, final boolean disableIndelQuals, final int preserveQLessThan, final boolean emitOriginalQuals, final double globalQScorePrior) { + public BaseRecalibration(final File RECAL_FILE, final int quantizationLevels, final boolean disableIndelQuals, final int preserveQLessThan, final boolean emitOriginalQuals, final double globalQScorePrior, final List staticQuantizedQuals, final boolean roundDown) { RecalibrationReport recalibrationReport = new RecalibrationReport(RECAL_FILE); recalibrationTables = recalibrationReport.getRecalibrationTables(); @@ -109,6 +114,15 @@ public class BaseRecalibration { this.preserveQLessThan = preserveQLessThan; this.globalQScorePrior = globalQScorePrior; this.emitOriginalQuals = emitOriginalQuals; + + // staticQuantizedQuals is entirely separate from the dynamic binning that quantizationLevels, and + // staticQuantizedQuals does not make use of quantizationInfo + if(staticQuantizedQuals != null) { + if(staticQuantizedQuals.isEmpty()) { + throw new IllegalStateException("List of static quantized quals is empty."); + } + staticQuantizedMapping = constructStaticQuantizedMapping(staticQuantizedQuals, roundDown); + } } /** @@ -184,7 +198,13 @@ public class BaseRecalibration { // return the quantized version of the recalibrated quality final byte recalibratedQualityScore = quantizationInfo.getQuantizedQuals().get(recalibratedQual); - quals[offset] = recalibratedQualityScore; + // Bin to static quals + if(staticQuantizedMapping != null) { + quals[offset] = staticQuantizedMapping[recalibratedQualityScore]; + } + else { + quals[offset] = recalibratedQualityScore; + } } } } @@ -194,6 +214,67 @@ public class BaseRecalibration { } } + /** + * Constructs an array that maps particular quantized values to a rounded value in staticQuantizedQuals + * + * Rounding is done in probability space. When roundDown is true, we simply round down to the nearest + * available qual in staticQuantizedQuals + * + * @param staticQuantizedQuals the list of qualities to round to + * @param roundDown round down if true, round to nearest (in probability space) otherwise + * @return Array where index representing the quality score to be mapped and the value is the rounded quality score + */ + protected static byte[] constructStaticQuantizedMapping(List staticQuantizedQuals, boolean roundDown) { + // Create array mapping that maps quals to their rounded value. + byte[] mapping = new byte[QualityUtils.MAX_QUAL]; + + Collections.sort(staticQuantizedQuals); + Iterator quantizationIterator = staticQuantizedQuals.iterator(); + + // Fill mapping with one-to-one mappings for values between 0 and MIN_USABLE_Q_SCORE + // This ensures that quals used as special codes will be preserved + for(int i = 0 ; i < QualityUtils.MIN_USABLE_Q_SCORE ; i++) { + mapping[i] = (byte) i; + } + + // If only one staticQuantizedQual is given, fill mappings larger than QualityUtils.MAX_QUAL with that value + if(staticQuantizedQuals.size() == 1) { + int onlyQual = quantizationIterator.next(); + for(int i = QualityUtils.MIN_USABLE_Q_SCORE ; i < QualityUtils.MAX_QUAL ; i++) { + mapping[i] = (byte) onlyQual; + } + return mapping; + } + + int firstQual = QualityUtils.MIN_USABLE_Q_SCORE; + int previousQual = firstQual; + double previousProb = QualityUtils.qualToProb(previousQual); + while(quantizationIterator.hasNext()) { + final int nextQual = quantizationIterator.next(); + final double nextProb = QualityUtils.qualToProb(nextQual); + + for (int i = previousQual ; i < nextQual ; i++) { + if (roundDown) { + mapping[i] = (byte) previousQual; + } else { + final double iProb = QualityUtils.qualToProb(i); + if ((iProb - previousProb) > (nextProb - iProb)) { + mapping[i] = (byte) nextQual; + } else { + mapping[i] = (byte) previousQual; + } + } + } + previousQual = nextQual; + previousProb = nextProb; + } + // Round all quals larger than the largest static qual down to the largest static qual + for(int j = previousQual ; j < QualityUtils.MAX_QUAL ; j++) { + mapping[j] = (byte) previousQual; + } + return mapping; + } + @Ensures("result > 0.0") protected static double hierarchicalBayesianQualityEstimate( final double epsilon, final RecalDatum empiricalQualRG, final RecalDatum empiricalQualQS, final List empiricalQualCovs ) { final double globalDeltaQ = ( empiricalQualRG == null ? 0.0 : empiricalQualRG.getEmpiricalQuality(epsilon) - epsilon ); diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibrationUnitTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibrationUnitTest.java new file mode 100644 index 000000000..218377582 --- /dev/null +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/engine/recalibration/BaseRecalibrationUnitTest.java @@ -0,0 +1,116 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE +* SOFTWARE LICENSE AGREEMENT +* FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 415 Main Street, Cambridge, MA 02142 (“BROAD”) and the LICENSEE and is effective at the date the downloading is completed (“EFFECTIVE DATE”). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK3 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute.org/gatk on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. LICENSEE hereby automatically grants to BROAD a non-exclusive, royalty-free, irrevocable license to any LICENSEE bug fixes or modifications to the PROGRAM with unlimited rights to sublicense and/or distribute. LICENSEE agrees to provide any such modifications and bug fixes to BROAD promptly upon their creation. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. PHONE-HOME FEATURE +* LICENSEE expressly acknowledges that the PROGRAM contains an embedded automatic reporting system (“PHONE-HOME”) which is enabled by default upon download. Unless LICENSEE requests disablement of PHONE-HOME, LICENSEE agrees that BROAD may collect limited information transmitted by PHONE-HOME regarding LICENSEE and its use of the PROGRAM. Such information shall include LICENSEE’S user identification, version number of the PROGRAM and tools being run, mode of analysis employed, and any error reports generated during run-time. Collection of such information is used by BROAD solely to monitor usage rates, fulfill reporting requirements to BROAD funding agencies, drive improvements to the PROGRAM, and facilitate adjustments to PROGRAM-related documentation. +* +* 4. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012-2015 Broad Institute, Inc. +* Notice of attribution: The GATK3 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 5. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 6. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 7. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 8. MISCELLANEOUS +* 8.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 8.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 8.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 8.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 8.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 8.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 8.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.gatk.engine.recalibration; + +import org.broadinstitute.gatk.utils.BaseTest; +import org.broadinstitute.gatk.utils.QualityUtils; +import org.broadinstitute.gatk.utils.exceptions.UserException; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class BaseRecalibrationUnitTest { + + @Test + public void repeatedAndUnorderedFixedQualities() { + // Test both repeated quals, and quals that aren't input in order + List quantizedQualsOrdered = Arrays.asList(11, 19); + List quantizedQualsUnordered = Arrays.asList(19, 11, 19, 19); + + // Unordered and Ordered qmapping should be identical + byte[] qmappingUnordered = BaseRecalibration.constructStaticQuantizedMapping(quantizedQualsUnordered, true); + byte[] qmappingOrdered = BaseRecalibration.constructStaticQuantizedMapping(quantizedQualsOrdered, true); + Assert.assertEquals(qmappingOrdered.length, qmappingUnordered.length); + for(int i = 0 ; i < qmappingUnordered.length ; i++) { + Assert.assertEquals(qmappingOrdered[i], qmappingUnordered[i]); + } + } + + @Test + public void nearestVsRoundDown() { + List fixedQuantizedQuals = Arrays.asList(10, 20, 30); + + byte[] qmappingRoundDown = BaseRecalibration.constructStaticQuantizedMapping(fixedQuantizedQuals, true); + byte[] qmappingRoundNearest = BaseRecalibration.constructStaticQuantizedMapping(fixedQuantizedQuals, false); + + // Depending on rounding strategy, bin 19 should round to 10 or 20 + Assert.assertEquals(qmappingRoundDown[19], 10); + Assert.assertEquals(qmappingRoundNearest[19], 20); + + // Regarless of rounding strategy, bin 21 should always round down to 20 + Assert.assertEquals(qmappingRoundDown[21], 20); + Assert.assertEquals(qmappingRoundNearest[21], 20); + } + + @Test + public void onlyOneFixedQualUsed() { + // Set all qualities to singleQual value (except for those below MIN_USABLE_Q_SCORE) + int singleQual = 10; + List fixedQuantizedQuals = Arrays.asList(singleQual); + + byte[] qmapping = BaseRecalibration.constructStaticQuantizedMapping(fixedQuantizedQuals, true); + + for(int i = 0 ; i < qmapping.length ; i++) { + if(i >= QualityUtils.MIN_USABLE_Q_SCORE) { + Assert.assertEquals(qmapping[i], singleQual); + } + else { + // Make sure that all values less than MIN_USABLE_Q_SCORE are preserved + Assert.assertEquals(qmapping[i], i); + } + } + } +} diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/bqsr/BQSRIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/bqsr/BQSRIntegrationTest.java index 25e03f1ff..a0382df91 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/bqsr/BQSRIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/bqsr/BQSRIntegrationTest.java @@ -52,6 +52,8 @@ package org.broadinstitute.gatk.tools.walkers.bqsr; import org.broadinstitute.gatk.engine.walkers.WalkerTest; +import org.broadinstitute.gatk.utils.commandline.ArgumentException; +import org.broadinstitute.gatk.utils.exceptions.GATKException; import org.broadinstitute.gatk.utils.exceptions.UserException; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -199,7 +201,8 @@ public class BQSRIntegrationTest extends WalkerTest { tests.add(new Object[]{1, new PRTest(" -qq -1", "8a38828e3b14ce067614d4248e3ea95a")}); tests.add(new Object[]{1, new PRTest(" -qq 6", "e4f23250b2c87f0d68d042cc3d2ec1d3")}); tests.add(new Object[]{1, new PRTest(" -DIQ", "2dfa45f004d3a371fd290ed67fbdf573")}); - + tests.add(new Object[]{1, new PRTest(" --useOriginalQualities -SQQ 10 -SQQ 20 -SQQ 30", "4882354d9e603f9bbe7c9591bba0a573")}); + tests.add(new Object[]{1, new PRTest(" --useOriginalQualities -SQQ 10 -SQQ 20 -SQQ 30 -RDQ", "6ffdfc4593e83f7c234b6249412433af")}); for ( final int nct : Arrays.asList(1, 2, 4) ) { tests.add(new Object[]{nct, new PRTest("", "6451093cadfc14d7359617b2a7ea6db8")}); } @@ -264,4 +267,36 @@ public class BQSRIntegrationTest extends WalkerTest { UserException.class); executeTest("testPRFailWithBadPL", spec); } + + @Test + public void testPRWithConflictingArguments_qqAndSQQ() { + // -qq and -SQQ shouldn't be able to be run in the same command + WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( + " -T PrintReads" + + " -R " + hg18Reference + + " -I " + HiSeqBam + + " -L " + HiSeqInterval + + " -qq 4 -SQQ 9" + + " -BQSR " + privateTestDir + "HiSeq.1mb.1RG.highMaxCycle.table" + + " -o /dev/null", + 0, + ArgumentException.class); + executeTest("testPRWithConflictingArguments_qqAndSQQ", spec); + } + + @Test + public void testPRWithConflictingArguments_qlAndSQQ() { + // Arguments -SQQ and -ql conflict and should throw an exception + WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( + " -T PrintReads" + + " -R " + hg18Reference + + " -I " + HiSeqBam + + " -L " + HiSeqInterval + + " -SQQ 4 -q1 4 " + + " -BQSR " + privateTestDir + "HiSeq.1mb.1RG.lowMaxCycle.table" + + " -o /dev/null", + 0, + ArgumentException.class); + executeTest("testPRWithConflictingArguments_qlAndSQQ", spec); + } } diff --git a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/arguments/GATKArgumentCollection.java b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/arguments/GATKArgumentCollection.java index 610467f70..ddc53c0db 100644 --- a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/arguments/GATKArgumentCollection.java +++ b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/arguments/GATKArgumentCollection.java @@ -333,7 +333,26 @@ public class GATKArgumentCollection { * Any value greater than zero will be used to recalculate the quantization using that many levels. * Negative values mean that we should quantize using the recalibration report's quantization level. */ + + + /** + * 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. + */ @Advanced + @Argument(fullName="static_quantized_quals", shortName = "SQQ", doc = "Use static quantized quality scores to a given number of levels (with -BQSR)", required=false, exclusiveOf = "quantize_quals", minValue = QualityUtils.MIN_USABLE_Q_SCORE, maxValue = QualityUtils.MAX_QUAL) + public List staticQuantizationQuals = null; + + /** + * Round down quantized only works with the static_quantized_quals option, and should not be used with + * the dynamic binning option provided by quantize_quals. When roundDown = false, rounding is done in + * probability space to the nearest bin. When roundDown = true, the value is rounded to the nearest bin + * that is smaller than the current bin. + */ + @Advanced + @Argument(fullName="round_down_quantized", shortName = "RDQ", doc = "Round quals down to nearest quantized qual", required=false, exclusiveOf="quantize_quals") + public boolean roundDown = false; + @Argument(fullName="quantize_quals", shortName = "qq", doc = "Quantize quality scores to a given number of levels (with -BQSR)", required=false) public int quantizationLevels = 0; diff --git a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRArgumentSet.java b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRArgumentSet.java index 9d3b6d100..491451103 100644 --- a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRArgumentSet.java +++ b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/recalibration/BQSRArgumentSet.java @@ -28,11 +28,14 @@ package org.broadinstitute.gatk.engine.recalibration; import org.broadinstitute.gatk.engine.arguments.GATKArgumentCollection; import java.io.File; +import java.util.List; public class BQSRArgumentSet { // declare public, STL-style for easier and more efficient access: private File BQSR_RECAL_FILE; private int quantizationLevels; + private List staticQuantizedQuals; + private boolean roundDown; private boolean disableIndelQuals; private boolean emitOriginalQuals; private int PRESERVE_QSCORES_LESS_THAN; @@ -41,6 +44,8 @@ public class BQSRArgumentSet { public BQSRArgumentSet(final GATKArgumentCollection args) { this.BQSR_RECAL_FILE = args.BQSR_RECAL_FILE; this.quantizationLevels = args.quantizationLevels; + this.staticQuantizedQuals = args.staticQuantizationQuals; + this.roundDown = args.roundDown; this.disableIndelQuals = args.disableIndelQuals; this.emitOriginalQuals = args.emitOriginalQuals; this.PRESERVE_QSCORES_LESS_THAN = args.PRESERVE_QSCORES_LESS_THAN; @@ -51,6 +56,10 @@ public class BQSRArgumentSet { public int getQuantizationLevels() { return quantizationLevels; } + public List getStaticQuantizedQuals() {return staticQuantizedQuals; } + + public boolean getRoundDown() {return roundDown; } + public boolean shouldDisableIndelQuals() { return disableIndelQuals; } public boolean shouldEmitOriginalQuals() { return emitOriginalQuals; } @@ -67,6 +76,12 @@ public class BQSRArgumentSet { this.quantizationLevels = quantizationLevels; } + public void setStaticQuantizedQuals(final List staticQuantizedQuals) { this.staticQuantizedQuals = staticQuantizedQuals; } + + public void setRoundDown(final boolean roundDown) { + this.roundDown = roundDown; + } + public void setDisableIndelQuals(final boolean disableIndelQuals) { this.disableIndelQuals = disableIndelQuals; }