diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/LeftAlignAndTrimVariantsIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/LeftAlignAndTrimVariantsIntegrationTest.java index 1bcbc50e3..9cb294497 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/LeftAlignAndTrimVariantsIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/LeftAlignAndTrimVariantsIntegrationTest.java @@ -175,4 +175,22 @@ public class LeftAlignAndTrimVariantsIntegrationTest extends WalkerTest { Arrays.asList("67657ee509665fd0d7a2c9024981ba92")); executeTest("test left alignment of multiple alleles with genoptypes, keep original AC", spec); } + + @Test + public void testSplitLeftAlignmentWithMultiallelicNoCallGenotypes() { + WalkerTestSpec spec = new WalkerTestSpec( + "-T LeftAlignAndTrimVariants -o %s -R " + hg19ReferenceWithChrPrefixInChromosomeNames + " --variant:vcf " + privateTestDir + "multiallelic-nocall.vcf -L chr12:104350950-104350960 --no_cmdline_in_header -split", + 1, + Arrays.asList("c7ce4310117f993593ce35f586451c53")); + executeTest("test splitting left alignment of multiple alleles with no-call genoptypes", spec); + } + + @Test + public void testSplitLeftAlignmentWithMultiallelicBadAD() { + WalkerTestSpec spec = new WalkerTestSpec( + "-T LeftAlignAndTrimVariants -o %s -R " + hg19ReferenceWithChrPrefixInChromosomeNames + " --variant:vcf " + privateTestDir + "multiallelic-nocall-badAD.vcf -L chr12:104350950-104350960 --no_cmdline_in_header -split", + 1, + IllegalStateException.class); + executeTest("test splitting left alignment of multiple alleles with bad AD", spec); + } } diff --git a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/variant/GATKVariantContextUtils.java b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/variant/GATKVariantContextUtils.java index d67dd6c01..ce40acebe 100644 --- a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/variant/GATKVariantContextUtils.java +++ b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/variant/GATKVariantContextUtils.java @@ -927,7 +927,7 @@ public class GATKVariantContextUtils { final List best = new LinkedList<>(); final Allele ref = allelesToUse.get(0); for ( final Allele originalAllele : originalGT ) { - best.add(allelesToUse.contains(originalAllele) ? originalAllele : ref); + best.add((allelesToUse.contains(originalAllele) || originalAllele.isNoCall()) ? originalAllele : ref); } gb.alleles(best); break; @@ -1045,7 +1045,7 @@ public class GATKVariantContextUtils { else { final List biallelics = new LinkedList<>(); - // if any of the genotypes ar ehet-not-ref (i.e. 1/2), set all of them to no-call + // if any of the genotypes are het-not-ref (i.e. 1/2), set all of them to no-call final GenotypeAssignmentMethod genotypeAssignmentMethodUsed = hasHetNonRef(vc.getGenotypes()) ? GATKVariantContextUtils.GenotypeAssignmentMethod.SET_TO_NO_CALL_NO_ANNOTATIONS : genotypeAssignmentMethod; for ( final Allele alt : vc.getAlternateAlleles() ) { @@ -1466,6 +1466,10 @@ public class GATKVariantContextUtils { int currentIndex = 0; for ( int i = alleleIndexesToUse.nextSetBit(0); i >= 0; i = alleleIndexesToUse.nextSetBit(i+1) ) { + if ( i >= oldAD.length ) { + throw new IllegalStateException("AD has " + oldAD.length + " items. It should have at least " + (i+1) + "."); + } + newAD[currentIndex++] = oldAD[i]; }