Work around for GSA-513: ClassCastException in VariantEval
This commit is contained in:
parent
f1166d6d00
commit
1999b95754
|
|
@ -45,12 +45,22 @@ public class AlleleCount extends VariantStratifier {
|
||||||
if (eval != null) {
|
if (eval != null) {
|
||||||
int AC = 0; // by default, the site is considered monomorphic
|
int AC = 0; // by default, the site is considered monomorphic
|
||||||
|
|
||||||
if ( eval.hasAttribute(VCFConstants.MLE_ALLELE_COUNT_KEY) && eval.isBiallelic() ) {
|
try {
|
||||||
// the MLEAC is allowed to be larger than the AN (e.g. in the case of all PLs being 0, the GT is ./. but the exact model may arbitrarily choose an AC>1)
|
if ( eval.isBiallelic() ) {
|
||||||
AC = Math.min(eval.getAttributeAsInt(VCFConstants.MLE_ALLELE_COUNT_KEY, 0), nchrom);
|
if ( eval.hasAttribute(VCFConstants.MLE_ALLELE_COUNT_KEY) ) {
|
||||||
} else if ( eval.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) && eval.isBiallelic() ) {
|
// the MLEAC is allowed to be larger than the AN (e.g. in the case of all PLs being 0, the GT is ./. but the exact model may arbitrarily choose an AC>1)
|
||||||
AC = eval.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY, 0);
|
AC = Math.min(eval.getAttributeAsInt(VCFConstants.MLE_ALLELE_COUNT_KEY, 0), nchrom);
|
||||||
} else if ( eval.isVariant() ) {
|
} else if ( eval.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) ) {
|
||||||
|
AC = eval.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch ( ClassCastException e ) {
|
||||||
|
// protect ourselves from bad inputs
|
||||||
|
// TODO -- fully decode VC
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( AC == 0 && eval.isVariant() ) {
|
||||||
|
// fall back to the direct calculation
|
||||||
for (Allele allele : eval.getAlternateAlleles())
|
for (Allele allele : eval.getAlternateAlleles())
|
||||||
AC = Math.max(AC, eval.getCalledChrCount(allele));
|
AC = Math.max(AC, eval.getCalledChrCount(allele));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue