Merge pull request #1553 from broadinstitute/rhl_latv_split_nocall_1518

Fix LeftAlignAndTrimVariants -split to not change no-call genotypes to hom-ref
This commit is contained in:
Ron Levine 2017-02-22 18:54:26 -05:00 committed by GitHub
commit 5c178c2a84
2 changed files with 24 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -927,7 +927,7 @@ public class GATKVariantContextUtils {
final List<Allele> 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<VariantContext> 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];
}