diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java index 80a95239c..5c2985720 100644 --- a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java +++ b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java @@ -366,12 +366,17 @@ public class HaplotypeCaller extends ActiveRegionWalker, In * sites are compressed into bands of similar genotype quality (GQ) that are emitted as a single VCF record. See * the FAQ documentation for more details about the GVCF format. * - * This argument allows you to set the GQ boundaries. HC expects a list of multiple GQ threshold values. To pass - * multiple values, you provide them one by one with the argument, as in `-GQB 10 -GQB 20 -GQB 30` and so on. Note - * that GQ values are capped at 99 in the GATK, so values must be integers in [1, 99]. + * This argument allows you to set the GQ bands. HC expects a list of strictly increasing GQ values + * that will act as exclusive upper bounds for the GQ bands. To pass multiple values, + * you provide them one by one with the argument, as in `-GQB 10 -GQB 20 -GQB 30` and so on + * (this would set the GQ bands to be `[0, 10), [10, 20), [20, 30)` and so on, for example). + * Note that GQ values are capped at 99 in the GATK, so values must be integers in [1, 100]. + * If the last value is strictly less than 100, the last GQ band will start at that value (inclusive) + * and end at 100 (exclusive). */ @Advanced - @Argument(fullName="GVCFGQBands", shortName="GQB", doc="GQ thresholds for reference confidence bands (must be in [1, 99] and specified in increasing order)", required = false) + @Argument(fullName="GVCFGQBands", shortName="GQB", doc="Exclusive upper bounds for reference confidence GQ bands " + + "(must be in [1, 100] and specified in increasing order)", required = false) protected List GVCFGQBands = new ArrayList(70) {{ for (int i=1; i<=60; ++i) add(i); add(70); add(80); add(90); add(99); diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriter.java b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriter.java index 23d6dbb2d..9bdee19e0 100644 --- a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriter.java +++ b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriter.java @@ -98,20 +98,34 @@ public class GVCFWriter implements VariantContextWriter { * @return a non-null string if something is wrong (string explains issue) */ protected static List parsePartitions(final List GQPartitions, final int defaultPloidy) { - if ( GQPartitions == null ) throw new IllegalArgumentException("The list of GQ partitions cannot be null."); - if ( GQPartitions.isEmpty() ) throw new IllegalArgumentException("The list of GQ partitions cannot be empty."); + if ( GQPartitions == null ) { + throw new IllegalArgumentException("The list of GQ partitions cannot be null."); + } + if ( GQPartitions.isEmpty() ) { + throw new IllegalArgumentException("The list of GQ partitions cannot be empty."); + } final List result = new LinkedList<>(); int lastThreshold = 0; for ( final Integer value : GQPartitions ) { - if ( value == null || value <= 0 ) throw new IllegalArgumentException("The list of GQ partitions contains a null or non-positive integer."); - if ( value < lastThreshold ) throw new IllegalArgumentException(String.format("The list of GQ partitions is out of order. Previous value is %d but the next is %d.", lastThreshold, value)); - if ( value == lastThreshold ) throw new IllegalArgumentException(String.format("The value %d appears more than once in the list of GQ partitions.", value)); - if ( value > MAX_GENOTYPE_QUAL ) throw new IllegalArgumentException(String.format("The value %d in the list of GQ partitions is greater than VCFConstants.MAX_GENOTYPE_QUAL = %d.", value, VCFConstants.MAX_GENOTYPE_QUAL)); + if ( value == null || value <= 0 ) { + throw new IllegalArgumentException("The list of GQ partitions contains a null or non-positive integer."); + } + if ( value < lastThreshold ) { + throw new IllegalArgumentException(String.format("The list of GQ partitions is out of order. " + + "Previous value is %d but the next is %d.", lastThreshold, value)); + } + if ( value == lastThreshold ) { + throw new IllegalArgumentException(String.format("The value %d appears more than once in the list of GQ partitions.", value)); + } + if ( value > MAX_GENOTYPE_QUAL + 1 ) { + throw new IllegalArgumentException(String.format("The value %d in the list of GQ partitions is " + + "greater than VCFConstants.MAX_GENOTYPE_QUAL + 1 = %d.", value, VCFConstants.MAX_GENOTYPE_QUAL + 1)); + } result.add(new HomRefBlock(lastThreshold, value, defaultPloidy)); lastThreshold = value; } - if (lastThreshold <= MAX_GENOTYPE_QUAL ) { + if ( lastThreshold <= MAX_GENOTYPE_QUAL ) { result.add(new HomRefBlock(lastThreshold, MAX_GENOTYPE_QUAL + 1, defaultPloidy)); } return result; diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java index ddc6587dd..402184e33 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java @@ -441,7 +441,7 @@ public class HaplotypeCallerGVCFIntegrationTest extends WalkerTest { {Arrays.asList(-1, 10, 20)}, {Arrays.asList(10, 20, 1)}, {Arrays.asList(10, 10, 20)}, - {Arrays.asList(10, 20, VCFConstants.MAX_GENOTYPE_QUAL + 1)} + {Arrays.asList(10, 20, VCFConstants.MAX_GENOTYPE_QUAL + 2)} }; } @Test(dataProvider = "dataBadGQBValues") diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriterUnitTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriterUnitTest.java index 7067fd89f..34a19adce 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriterUnitTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/utils/gvcf/GVCFWriterUnitTest.java @@ -390,7 +390,9 @@ public class GVCFWriterUnitTest extends BaseTest { tests.add(new Object[]{Arrays.asList(1, 1, 10), false, null}); tests.add(new Object[]{Arrays.asList(1, 10, VCFConstants.MAX_GENOTYPE_QUAL - 1), true, Arrays.asList(0, 1, 10, VCFConstants.MAX_GENOTYPE_QUAL - 1)}); tests.add(new Object[]{Arrays.asList(1, 10, VCFConstants.MAX_GENOTYPE_QUAL), true, Arrays.asList(0, 1, 10, VCFConstants.MAX_GENOTYPE_QUAL)}); - tests.add(new Object[]{Arrays.asList(1, 10, VCFConstants.MAX_GENOTYPE_QUAL + 1), false, null}); + tests.add(new Object[]{Arrays.asList(1, 10, VCFConstants.MAX_GENOTYPE_QUAL + 1), true, Arrays.asList(0, 1, 10)}); + tests.add(new Object[]{Collections.singletonList(VCFConstants.MAX_GENOTYPE_QUAL + 1), true, Collections.singletonList(0)}); + tests.add(new Object[]{Arrays.asList(1, 10, VCFConstants.MAX_GENOTYPE_QUAL + 2), false, null}); return tests.toArray(new Object[][]{}); }