Merge pull request #1451 from broadinstitute/sl_issue_1345_fix_2

Changed maximum allowed GQB value to 100.
This commit is contained in:
samuelklee 2016-08-05 15:12:20 -04:00 committed by GitHub
commit 7959324f08
4 changed files with 34 additions and 13 deletions

View File

@ -366,12 +366,17 @@ public class HaplotypeCaller extends ActiveRegionWalker<List<VariantContext>, In
* sites are compressed into bands of similar genotype quality (GQ) that are emitted as a single VCF record. See * 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. * 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 * This argument allows you to set the GQ bands. HC expects a list of strictly increasing GQ values
* multiple values, you provide them one by one with the argument, as in `-GQB 10 -GQB 20 -GQB 30` and so on. Note * that will act as exclusive upper bounds for the GQ bands. To pass multiple values,
* that GQ values are capped at 99 in the GATK, so values must be integers in [1, 99]. * 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 @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<Integer> GVCFGQBands = new ArrayList<Integer>(70) {{ protected List<Integer> GVCFGQBands = new ArrayList<Integer>(70) {{
for (int i=1; i<=60; ++i) add(i); for (int i=1; i<=60; ++i) add(i);
add(70); add(80); add(90); add(99); add(70); add(80); add(90); add(99);

View File

@ -98,20 +98,34 @@ public class GVCFWriter implements VariantContextWriter {
* @return a non-null string if something is wrong (string explains issue) * @return a non-null string if something is wrong (string explains issue)
*/ */
protected static List<HomRefBlock> parsePartitions(final List<Integer> GQPartitions, final int defaultPloidy) { protected static List<HomRefBlock> parsePartitions(final List<Integer> GQPartitions, final int defaultPloidy) {
if ( GQPartitions == null ) throw new IllegalArgumentException("The list of GQ partitions cannot be null."); if ( GQPartitions == null ) {
if ( GQPartitions.isEmpty() ) throw new IllegalArgumentException("The list of GQ partitions cannot be empty."); 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<HomRefBlock> result = new LinkedList<>(); final List<HomRefBlock> result = new LinkedList<>();
int lastThreshold = 0; int lastThreshold = 0;
for ( final Integer value : GQPartitions ) { 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 == null || value <= 0 ) {
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)); throw new IllegalArgumentException("The list of GQ partitions contains a null or non-positive integer.");
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 < 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)); result.add(new HomRefBlock(lastThreshold, value, defaultPloidy));
lastThreshold = value; lastThreshold = value;
} }
if (lastThreshold <= MAX_GENOTYPE_QUAL ) { if ( lastThreshold <= MAX_GENOTYPE_QUAL ) {
result.add(new HomRefBlock(lastThreshold, MAX_GENOTYPE_QUAL + 1, defaultPloidy)); result.add(new HomRefBlock(lastThreshold, MAX_GENOTYPE_QUAL + 1, defaultPloidy));
} }
return result; return result;

View File

@ -441,7 +441,7 @@ public class HaplotypeCallerGVCFIntegrationTest extends WalkerTest {
{Arrays.asList(-1, 10, 20)}, {Arrays.asList(-1, 10, 20)},
{Arrays.asList(10, 20, 1)}, {Arrays.asList(10, 20, 1)},
{Arrays.asList(10, 10, 20)}, {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") @Test(dataProvider = "dataBadGQBValues")

View File

@ -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, 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 - 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), 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[][]{}); return tests.toArray(new Object[][]{});
} }