Skip to content

Commit 5b87367

Browse files
authored
Fix bug which caused --max_alternate_alleles to be ignored when using GenomicsDB (#7576)
* Fix a bug where --max_alternate_alleles was being ignored instead of being passed to GenomicsDB * Cleanup some variable names which shouldn't have been uppercase
1 parent 9c7eaf7 commit 5b87367

File tree

11 files changed

+58
-32
lines changed

11 files changed

+58
-32
lines changed

src/main/java/org/broadinstitute/hellbender/tools/genomicsdb/GenomicsDBOptions.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,24 @@ public GenomicsDBOptions(final Path reference) {
2525
}
2626

2727
public GenomicsDBOptions(final Path reference, GenomicsDBArgumentCollection genomicsdbArgs) {
28-
this(reference, genomicsdbArgs, new GenotypeCalculationArgumentCollection(), false);
28+
this(reference, genomicsdbArgs, new GenotypeCalculationArgumentCollection());
2929
}
3030

3131
public GenomicsDBOptions(final Path reference, final GenomicsDBArgumentCollection genomicsdbArgs,
32-
final GenotypeCalculationArgumentCollection genotypeCalcArgs, final boolean forceCallGenotypes) {
32+
final GenotypeCalculationArgumentCollection genotypeCalcArgs) {
3333
this.reference = reference;
34-
this.callGenotypes = genomicsdbArgs.callGenotypes || forceCallGenotypes;
35-
this.maxDiploidAltAllelesThatCanBeGenotyped = genomicsdbArgs.maxDiploidAltAllelesThatCanBeGenotyped;
36-
this.maxGenotypeCount = genotypeCalcArgs.MAX_GENOTYPE_COUNT;
34+
this.callGenotypes = genomicsdbArgs.callGenotypes;
3735
this.useBCFCodec = genomicsdbArgs.useBCFCodec;
3836
this.sharedPosixFSOptimizations = genomicsdbArgs.sharedPosixFSOptimizations;
3937
this.useGcsHdfsConnector = genomicsdbArgs.useGcsHdfsConnector;
38+
if (genotypeCalcArgs != null) {
39+
this.maxDiploidAltAllelesThatCanBeGenotyped = genotypeCalcArgs.maxAlternateAlleles;
40+
this.maxGenotypeCount = genotypeCalcArgs.maxGenotypeCount;
41+
} else {
42+
// Some defaults
43+
this.maxDiploidAltAllelesThatCanBeGenotyped = genomicsdbArgs.maxDiploidAltAllelesThatCanBeGenotyped;
44+
this.maxGenotypeCount = GenotypeCalculationArgumentCollection.DEFAULT_MAX_GENOTYPE_COUNT;
45+
}
4046
}
4147

4248
public Path getReference() {

src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFs.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ public boolean requiresReference() {
208208

209209
@Override
210210
protected GenomicsDBOptions getGenomicsDBOptions() {
211-
//extract called genotypes so hom refs with no PLs aren't ambiguous
212211
if (genomicsDBOptions == null) {
213-
genomicsDBOptions = new GenomicsDBOptions(referenceArguments.getReferencePath(), genomicsdbArgs, genotypeArgs, true);
212+
//extract called genotypes so hom refs with no PLs aren't ambiguous
213+
genomicsdbArgs.callGenotypes = true;
214+
genomicsDBOptions = new GenomicsDBOptions(referenceArguments.getReferencePath(), genomicsdbArgs, genotypeArgs);
214215
}
215216
return genomicsDBOptions;
216217
}

src/main/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsEngine.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private VariantContext callSomaticGenotypes(final VariantContext vc, double tlod
300300
final VariantContextBuilder builder = new VariantContextBuilder(vc);
301301
final VariantContext regenotypedVC = builder.genotypes(newGenotypes).make();
302302

303-
final int maxAltAlleles = genotypingEngine.getConfiguration().genotypeArgs.MAX_ALTERNATE_ALLELES;
303+
final int maxAltAlleles = genotypingEngine.getConfiguration().genotypeArgs.maxAlternateAlleles;
304304
List<Allele> allelesToKeep;
305305

306306
//we need to make sure all alleles pass the tlodThreshold

src/main/java/org/broadinstitute/hellbender/tools/walkers/genotyper/GenotypeCalculationArgumentCollection.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.broadinstitute.barclay.argparser.Argument;
66
import org.broadinstitute.hellbender.engine.FeatureInput;
77
import org.broadinstitute.hellbender.exceptions.GATKException;
8-
import org.broadinstitute.hellbender.utils.Utils;
98
import org.broadinstitute.hellbender.utils.variant.HomoSapiensConstants;
109

1110
import java.io.Serializable;
@@ -127,19 +126,19 @@ public GenotypeCalculationArgumentCollection clone() {
127126
* Note that the default was changed from 10.0 to 30.0 in version 4.1.0.0 to accompany the switch to use the the new quality score by default.
128127
*/
129128
@Argument(fullName = CALL_CONFIDENCE_LONG_NAME, shortName = CALL_CONFIDENCE_SHORT_NAME, doc = "The minimum phred-scaled confidence threshold at which variants should be called", optional = true)
130-
public double STANDARD_CONFIDENCE_FOR_CALLING = DEFAULT_STANDARD_CONFIDENCE_FOR_CALLING;
129+
public double standardConfidenceForCalling = DEFAULT_STANDARD_CONFIDENCE_FOR_CALLING;
131130

132131
/**
133132
* If there are more than this number of alternate alleles presented to the genotyper (either through discovery or GENOTYPE_GIVEN ALLELES),
134133
* then only this many alleles will be used. Note that genotyping sites with many alternate alleles is both CPU and memory intensive and it
135134
* scales exponentially based on the number of alternate alleles. Unless there is a good reason to change the default value, we highly recommend
136135
* that you not play around with this parameter.
137136
*
138-
* See also {@link #MAX_GENOTYPE_COUNT}.
137+
* See also {@link #maxGenotypeCount}.
139138
*/
140139
@Advanced
141140
@Argument(fullName = MAX_ALTERNATE_ALLELES_LONG_NAME, doc = "Maximum number of alternate alleles to genotype", optional = true)
142-
public int MAX_ALTERNATE_ALLELES = DEFAULT_MAX_ALTERNATE_ALLELES;
141+
public int maxAlternateAlleles = DEFAULT_MAX_ALTERNATE_ALLELES;
143142

144143
/**
145144
* If there are more than this number of genotypes at a locus presented to the genotyper, then only this many genotypes will be used.
@@ -152,17 +151,18 @@ public GenotypeCalculationArgumentCollection clone() {
152151
* Unless there is a good reason to change the default value, we highly recommend that you not play around with this parameter.
153152
*
154153
* The maximum number of alternative alleles used in the genotyping step will be the lesser of the two:
155-
* 1. the largest number of alt alleles, given ploidy, that yields a genotype count no higher than {@link #MAX_GENOTYPE_COUNT}
156-
* 2. the value of {@link #MAX_ALTERNATE_ALLELES}
154+
* 1. the largest number of alt alleles, given ploidy, that yields a genotype count no higher than {@link #maxGenotypeCount}
155+
* 2. the value of {@link #maxAlternateAlleles}
157156
*
158-
* See also {@link #MAX_ALTERNATE_ALLELES}.
157+
* See also {@link #maxAlternateAlleles}.
159158
*/
160159
@Advanced
161160
@Argument(fullName = MAX_GENOTYPE_COUNT_LONG_NAME, doc = "Maximum number of genotypes to consider at any site", optional = true)
162-
public int MAX_GENOTYPE_COUNT = DEFAULT_MAX_GENOTYPE_COUNT;
161+
public int maxGenotypeCount = DEFAULT_MAX_GENOTYPE_COUNT;
163162

164163
/**
165-
* Sample ploidy - equivalent to number of chromosomes per pool. In pooled experiments this should be = # of samples in pool * individual sample ploidy
164+
* Sample ploidy - equivalent to number of chromoso
165+
* mes per pool. In pooled experiments this should be = # of samples in pool * individual sample ploidy
166166
*/
167167
@Argument(shortName = SAMPLE_PLOIDY_SHORT_NAME, fullName = SAMPLE_PLOIDY_LONG_NAME, doc="Ploidy (number of chromosomes) per sample. For pooled data, set to (Number of samples in each pool * Sample Ploidy).", optional=true)
168168
public int samplePloidy = HomoSapiensConstants.DEFAULT_PLOIDY;

src/main/java/org/broadinstitute/hellbender/tools/walkers/genotyper/GenotypingEngine.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public VariantContext calculateGenotypes(final VariantContext vc, final Genotype
127127
}
128128

129129
final int defaultPloidy = configuration.genotypeArgs.samplePloidy;
130-
final int maxAltAlleles = configuration.genotypeArgs.MAX_ALTERNATE_ALLELES;
130+
final int maxAltAlleles = configuration.genotypeArgs.maxAlternateAlleles;
131131

132132
VariantContext reducedVC = vc;
133133
if (maxAltAlleles < vc.getAlternateAlleles().size()) {
@@ -305,7 +305,7 @@ private OutputAlleleSubset calculateOutputAlleleSubset(final AFCalculationResult
305305
// we want to keep the NON_REF symbolic allele but only in the absence of a non-symbolic allele, e.g.
306306
// if we combined a ref / NON_REF gVCF with a ref / alt gVCF
307307
final boolean isNonRefWhichIsLoneAltAllele = alternativeAlleleCount == 1 && allele.equals(Allele.NON_REF_ALLELE);
308-
final boolean isPlausible = afCalculationResult.passesThreshold(allele, configuration.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING);
308+
final boolean isPlausible = afCalculationResult.passesThreshold(allele, configuration.genotypeArgs.standardConfidenceForCalling);
309309

310310
//it's possible that the upstream deletion that spanned this site was not emitted, mooting the symbolic spanning deletion allele
311311
final boolean isSpuriousSpanningDeletion = GATKVCFConstants.isSpanningDeletion(allele) && !isVcCoveredByDeletion(vc);
@@ -414,7 +414,7 @@ protected final boolean passesEmitThreshold(final double conf, final boolean bes
414414
}
415415

416416
protected final boolean passesCallThreshold(final double conf) {
417-
return conf >= configuration.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING;
417+
return conf >= configuration.genotypeArgs.standardConfidenceForCalling;
418418
}
419419

420420
protected Map<String,Object> composeCallAttributes(final VariantContext vc, final List<Integer> alleleCountsofMLE,

src/main/java/org/broadinstitute/hellbender/tools/walkers/gnarlyGenotyper/GnarlyGenotyper.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ protected List<SimpleInterval> transformTraversalIntervals(final List<SimpleInte
173173
@Override
174174
protected GenomicsDBOptions getGenomicsDBOptions() {
175175
if (genomicsDBOptions == null) {
176-
genomicsdbArgs.maxDiploidAltAllelesThatCanBeGenotyped = PIPELINE_MAX_ALT_COUNT;
177-
genomicsDBOptions = new GenomicsDBOptions(referenceArguments.getReferencePath(), genomicsdbArgs, genotypeArgs, CALL_GENOTYPES);
176+
genomicsdbArgs.callGenotypes = CALL_GENOTYPES;
177+
genotypeArgs.maxAlternateAlleles = PIPELINE_MAX_ALT_COUNT;
178+
genomicsDBOptions = new GenomicsDBOptions(referenceArguments.getReferencePath(), genomicsdbArgs, genotypeArgs);
178179
}
179180
return genomicsDBOptions;
180181
}
@@ -195,7 +196,7 @@ public void onTraversalStart() {
195196

196197
setupVCFWriter(inputVCFHeader, samples);
197198

198-
genotyperEngine = new GnarlyGenotyperEngine(keepAllSites, genotypeArgs.MAX_ALTERNATE_ALLELES, SUMMARIZE_PLs, stripASAnnotations);
199+
genotyperEngine = new GnarlyGenotyperEngine(keepAllSites, genotypeArgs.maxAlternateAlleles, SUMMARIZE_PLs, stripASAnnotations);
199200

200201
Reflections reflections = new Reflections("org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific");
201202
//not InfoFieldAnnotation.class because we don't want AS_InbreedingCoeff

src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCaller.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public void onTraversalStart() {
249249
hcArgs.likelihoodArgs.enableDynamicReadDisqualification = true;
250250
hcArgs.likelihoodArgs.expectedErrorRatePerBase = 0.03;
251251
hcArgs.standardArgs.genotypeArgs.genotypeAssignmentMethod = GenotypeAssignmentMethod.USE_POSTERIOR_PROBABILITIES;
252-
hcArgs.standardArgs.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING = 3.0;
252+
hcArgs.standardArgs.genotypeArgs.standardConfidenceForCalling = 3.0;
253253
hcArgs.standardArgs.genotypeArgs.usePosteriorProbabilitiesToCalculateQual = true;
254254
assemblyRegionArgs.indelPaddingForGenotyping = 150;
255255
}

src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ private void validateAndInitializeArgs() {
280280
}
281281

282282
if ( emitReferenceConfidence() ) {
283-
hcArgs.standardArgs.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING = -0.0;
283+
hcArgs.standardArgs.genotypeArgs.standardConfidenceForCalling = -0.0;
284284

285285
logger.info("Standard Emitting and Calling confidence set to 0.0 for reference-model confidence output");
286286
if ( ! hcArgs.standardArgs.annotateAllSitesWithPLs ) {
@@ -333,7 +333,7 @@ private void initializeActiveRegionEvaluationGenotyperEngine() {
333333
activeRegionArgs.copyStandardCallerArgsFrom(hcArgs.standardArgs);
334334

335335
activeRegionArgs.outputMode = OutputMode.EMIT_VARIANTS_ONLY;
336-
activeRegionArgs.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING = Math.min(MAXMIN_CONFIDENCE_FOR_CONSIDERING_A_SITE_AS_POSSIBLE_VARIANT_IN_ACTIVE_REGION_DISCOVERY, hcArgs.standardArgs.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING ); // low values used for isActive determination only, default/user-specified values used for actual calling
336+
activeRegionArgs.genotypeArgs.standardConfidenceForCalling = Math.min(MAXMIN_CONFIDENCE_FOR_CONSIDERING_A_SITE_AS_POSSIBLE_VARIANT_IN_ACTIVE_REGION_DISCOVERY, hcArgs.standardArgs.genotypeArgs.standardConfidenceForCalling); // low values used for isActive determination only, default/user-specified values used for actual calling
337337
activeRegionArgs.CONTAMINATION_FRACTION = 0.0;
338338
activeRegionArgs.CONTAMINATION_FRACTION_FILE = null;
339339
// Seems that at least with some test data we can lose genuine haploid variation if we use ploidy == 1

src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public HaplotypeCallerGenotypingEngine(final HaplotypeCallerArgumentCollection c
7171
genotypingModel = hcArgs.applyBQD || hcArgs.applyFRD ?
7272
new DRAGENGenotypesModel(applyBQD, hcArgs.applyFRD, hcArgs.informativeReadOverlapMargin, hcArgs.maxEffectiveDepthAdjustment, dragstrParams) :
7373
new IndependentSampleGenotypesModel();
74-
maxGenotypeCountToEnumerate = configuration.standardArgs.genotypeArgs.MAX_GENOTYPE_COUNT;
74+
maxGenotypeCountToEnumerate = configuration.standardArgs.genotypeArgs.maxGenotypeCount;
7575
referenceConfidenceMode = configuration.emitReferenceConfidence;
7676
snpHeterozygosity = configuration.standardArgs.genotypeArgs.snpHeterozygosity;
7777
indelHeterozygosity = configuration.standardArgs.genotypeArgs.indelHeterozygosity;

src/main/java/org/broadinstitute/hellbender/tools/walkers/variantutils/ReblockGVCF.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private HaplotypeCallerGenotypingEngine createGenotypingEngine(final SampleList
257257
hcArgs.standardArgs.annotateAllSitesWithPLs = true;
258258
hcArgs.standardArgs.genotypeArgs = genotypeArgs.clone();
259259
hcArgs.emitReferenceConfidence = ReferenceConfidenceMode.GVCF; //this is important to force emission of all alleles at a multiallelic site
260-
hcArgs.standardArgs.genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING = dropLowQuals ? genotypeArgs.STANDARD_CONFIDENCE_FOR_CALLING : 0.0;
260+
hcArgs.standardArgs.genotypeArgs.standardConfidenceForCalling = dropLowQuals ? genotypeArgs.standardConfidenceForCalling : 0.0;
261261
return new HaplotypeCallerGenotypingEngine(hcArgs, samples, true, false);
262262

263263
}

src/test/java/org/broadinstitute/hellbender/tools/walkers/GenotypeGVCFsIntegrationTest.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,22 @@ public Object[][] getGVCFsForGenomicsDBOverMultipleIntervals() {
260260
public void assertMatchingGenotypesFromGenomicsDB(File input, File expected, Locatable interval, String reference) throws IOException {
261261
final File tempGenomicsDB = GenomicsDBTestUtils.createTempGenomicsDB(input, interval);
262262
final String genomicsDBUri = GenomicsDBTestUtils.makeGenomicsDBUri(tempGenomicsDB);
263-
runGenotypeGVCFSAndAssertSomething(genomicsDBUri, expected, NO_EXTRA_ARGS, VariantContextTestUtils::assertVariantContextsHaveSameGenotypes, reference);
263+
final List<String> args = new ArrayList<String>();
264+
args.add("--"+GenotypeCalculationArgumentCollection.MAX_ALTERNATE_ALLELES_LONG_NAME);
265+
args.add("2"); // Too small max_alternate_alleles arg to GenomicsDB, should fail
266+
try {
267+
File output = runGenotypeGVCFS(genomicsDBUri, expected, args, reference);
268+
Assert.fail("Expected exception not thrown");
269+
} catch (IllegalStateException e) {
270+
// Pass
271+
}
272+
273+
args.clear();
274+
args.add("--"+GenotypeCalculationArgumentCollection.MAX_ALTERNATE_ALLELES_LONG_NAME);
275+
args.add("8");
276+
runGenotypeGVCFSAndAssertSomething(genomicsDBUri, expected, args, VariantContextTestUtils::assertVariantContextsHaveSameGenotypes, reference);
264277

265278
// The default option with GenomicsDB input uses VCFCodec for decoding, test BCFCodec explicitly
266-
final List<String> args = new ArrayList<String>();
267279
args.add("--"+GenomicsDBArgumentCollection.USE_BCF_CODEC_LONG_NAME);
268280
runGenotypeGVCFSAndAssertSomething(genomicsDBUri, expected, args, VariantContextTestUtils::assertVariantContextsHaveSameGenotypes, reference);
269281
}
@@ -362,9 +374,8 @@ private void runGenotypeGVCFSAndAssertSomething(File input, File expected, List<
362374
);
363375
}
364376

365-
private void runGenotypeGVCFSAndAssertSomething(String input, File expected, List<String> additionalArguments, BiConsumer<VariantContext, VariantContext> assertion, String reference) throws IOException {
377+
private File runGenotypeGVCFS(String input, File expected, List<String> additionalArguments, String reference) {
366378
final File output = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expected : createTempFile("genotypegvcf", ".vcf");
367-
368379
final ArgumentsBuilder args = new ArgumentsBuilder();
369380
args.addReference(new File(reference))
370381
.add("V", input)
@@ -377,6 +388,13 @@ private void runGenotypeGVCFSAndAssertSomething(String input, File expected, Lis
377388
Utils.resetRandomGenerator();
378389
runCommandLine(args);
379390

391+
return output;
392+
}
393+
394+
private void runGenotypeGVCFSAndAssertSomething(String input, File expected, List<String> additionalArguments, BiConsumer<VariantContext, VariantContext> assertion, String reference) throws IOException {
395+
final File output = runGenotypeGVCFS(input, expected, additionalArguments, reference);
396+
Assert.assertTrue(output.exists());
397+
380398
if (! UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS) {
381399
final List<VariantContext> expectedVC = VariantContextTestUtils.getVariantContexts(expected);
382400
final List<VariantContext> actualVC = VariantContextTestUtils.getVariantContexts(output);

0 commit comments

Comments
 (0)