Fixed nasty bug in BCF2 writer for case where all genotypes are missing

-- Previous code was looking for a -1 result from maxPloidy() but the result as actually 0, so instead of writing a diploid no call we were actually writing "unavailable" genotypes, and failing the BCF == VCF test in integration tests.  Fixed.
This commit is contained in:
Mark DePristo 2012-09-12 06:41:36 -04:00
parent 91f3204534
commit d1ba17df5d
2 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,6 @@
package org.broadinstitute.sting.utils.variantcontext;
import com.google.java.contract.Ensures;
import com.google.java.contract.Invariant;
import com.google.java.contract.Requires;
import java.util.*;
@ -413,6 +412,11 @@ public class GenotypesContext implements List<Genotype> {
return getGenotypes().get(i);
}
/**
* What is the max ploidy among all samples? Returns 0 if no genotypes are present
*
* @return
*/
@Ensures("result >= 0")
public int getMaxPloidy() {
if ( maxPloidy == -1 ) {

View File

@ -275,7 +275,7 @@ public abstract class BCF2FieldWriter {
nValuesPerGenotype = vc.getMaxPloidy();
// deal with the case where we have no call everywhere, in which case we write out diploid
if ( nValuesPerGenotype == -1 )
if ( nValuesPerGenotype == 0 )
nValuesPerGenotype = 2;
super.start(encoder, vc);