Fix for JIRA GSA-598: AD field not handled properly by CombineVariants. It was also not handled by SelectVariants either. We now strip the AD field out whenever combining/selecting makes it invalid due to a changing of the number of ALT alleles.

This commit is contained in:
Eric Banks 2012-10-06 23:02:36 -04:00
parent bfc551f612
commit e7798ddd2a
3 changed files with 8 additions and 11 deletions

View File

@ -701,9 +701,9 @@ public class SelectVariants extends RodWalker<Integer, Integer> implements TreeR
GenotypesContext newGC = sub.getGenotypes(); GenotypesContext newGC = sub.getGenotypes();
// if we have fewer alternate alleles in the selected VC than in the original VC, we need to strip out the GL/PLs (because they are no longer accurate) // if we have fewer alternate alleles in the selected VC than in the original VC, we need to strip out the GL/PLs and AD (because they are no longer accurate)
if ( vc.getAlleles().size() != sub.getAlleles().size() ) if ( vc.getAlleles().size() != sub.getAlleles().size() )
newGC = VariantContextUtils.stripPLs(sub.getGenotypes()); newGC = VariantContextUtils.stripPLsAndAD(sub.getGenotypes());
// if we have fewer samples in the selected VC than in the original VC, we need to strip out the MLE tags // if we have fewer samples in the selected VC than in the original VC, we need to strip out the MLE tags
if ( vc.getNSamples() != sub.getNSamples() ) { if ( vc.getNSamples() != sub.getNSamples() ) {

View File

@ -157,11 +157,8 @@ public class VariantContextUtils {
builder.attributes(calculateChromosomeCounts(vc, new HashMap<String, Object>(vc.getAttributes()), removeStaleValues, founderIds)); builder.attributes(calculateChromosomeCounts(vc, new HashMap<String, Object>(vc.getAttributes()), removeStaleValues, founderIds));
} }
public static Genotype removePLs(Genotype g) { public static Genotype removePLsAndAD(final Genotype g) {
if ( g.hasLikelihoods() ) return ( g.hasLikelihoods() || g.hasAD() ) ? new GenotypeBuilder(g).noPL().noAD().make() : g;
return new GenotypeBuilder(g).noPL().make();
else
return g;
} }
public final static VCFCompoundHeaderLine getMetaDataForField(final VCFHeader header, final String field) { public final static VCFCompoundHeaderLine getMetaDataForField(final VCFHeader header, final String field) {
@ -581,7 +578,7 @@ public class VariantContextUtils {
if ( ! genotypes.isEmpty() ) if ( ! genotypes.isEmpty() )
logger.debug(String.format("Stripping PLs at %s due incompatible alleles merged=%s vs. single=%s", logger.debug(String.format("Stripping PLs at %s due incompatible alleles merged=%s vs. single=%s",
genomeLocParser.createGenomeLoc(vc), alleles, vc.alleles)); genomeLocParser.createGenomeLoc(vc), alleles, vc.alleles));
genotypes = stripPLs(genotypes); genotypes = stripPLsAndAD(genotypes);
// this will remove stale AC,AF attributed from vc // this will remove stale AC,AF attributed from vc
calculateChromosomeCounts(vc, attributes, true); calculateChromosomeCounts(vc, attributes, true);
break; break;
@ -672,11 +669,11 @@ public class VariantContextUtils {
return true; return true;
} }
public static GenotypesContext stripPLs(GenotypesContext genotypes) { public static GenotypesContext stripPLsAndAD(GenotypesContext genotypes) {
GenotypesContext newGs = GenotypesContext.create(genotypes.size()); GenotypesContext newGs = GenotypesContext.create(genotypes.size());
for ( final Genotype g : genotypes ) { for ( final Genotype g : genotypes ) {
newGs.add(g.hasLikelihoods() ? removePLs(g) : g); newGs.add(removePLsAndAD(g));
} }
return newGs; return newGs;

View File

@ -255,7 +255,7 @@ public class SelectVariantsIntegrationTest extends WalkerTest {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
"-T SelectVariants -R " + b37KGReference + " -o %s --no_cmdline_in_header -sf " + samplesFile + " --excludeNonVariants --variant " + testfile, "-T SelectVariants -R " + b37KGReference + " -o %s --no_cmdline_in_header -sf " + samplesFile + " --excludeNonVariants --variant " + testfile,
1, 1,
Arrays.asList("3ab35d5e81a29fb5db3e2add11c7e823") Arrays.asList("f14d75892b99547d8e9ba3a03bfb04ea")
); );
executeTest("test select from multi allelic with excludeNonVariants --" + testfile, spec); executeTest("test select from multi allelic with excludeNonVariants --" + testfile, spec);
} }