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:
parent
91f3204534
commit
d1ba17df5d
|
|
@ -25,7 +25,6 @@
|
||||||
package org.broadinstitute.sting.utils.variantcontext;
|
package org.broadinstitute.sting.utils.variantcontext;
|
||||||
|
|
||||||
import com.google.java.contract.Ensures;
|
import com.google.java.contract.Ensures;
|
||||||
import com.google.java.contract.Invariant;
|
|
||||||
import com.google.java.contract.Requires;
|
import com.google.java.contract.Requires;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -413,6 +412,11 @@ public class GenotypesContext implements List<Genotype> {
|
||||||
return getGenotypes().get(i);
|
return getGenotypes().get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What is the max ploidy among all samples? Returns 0 if no genotypes are present
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Ensures("result >= 0")
|
@Ensures("result >= 0")
|
||||||
public int getMaxPloidy() {
|
public int getMaxPloidy() {
|
||||||
if ( maxPloidy == -1 ) {
|
if ( maxPloidy == -1 ) {
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ public abstract class BCF2FieldWriter {
|
||||||
nValuesPerGenotype = vc.getMaxPloidy();
|
nValuesPerGenotype = vc.getMaxPloidy();
|
||||||
|
|
||||||
// deal with the case where we have no call everywhere, in which case we write out diploid
|
// 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;
|
nValuesPerGenotype = 2;
|
||||||
|
|
||||||
super.start(encoder, vc);
|
super.start(encoder, vc);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue