TruthState truthState = null;
CallState callState = null;
// TODO: what about getPloidy()
Genotype truthGenotype = null, callGenotype = null;
// Site level checks
if (truthContext == null) truthState = TruthState.MISSING;
else if (truthContext.isMixed()) truthState = TruthState.IS_MIXED;
else if (truthContext.isFiltered()) truthState = TruthState.VC_FILTERED;
else {
// Genotype level checks
truthGenotype = truthContext.getGenotype(truthSample);
if (truthGenotype.isNoCall()) truthState = TruthState.NO_CALL;
else if (truthGenotype.isFiltered()) truthState = TruthState.GT_FILTERED;
else if ((truthGenotype.getGQ() != -1) && (truthGenotype.getGQ() < minGq)) truthState = TruthState.LOW_GQ;
else if ((truthGenotype.getDP() != -1) && (truthGenotype.getDP() < minDp)) truthState = TruthState.LOW_DP;
// Note. Genotype.isMixed means that it is called on one chromosome and NOT on the other
else if ((truthGenotype.isMixed())) truthState = TruthState.NO_CALL;
}
// Site level checks
if (callContext == null) callState = CallState.MISSING;
else if (callContext.isMixed()) callState = CallState.IS_MIXED;
else if (callContext.isFiltered()) callState = CallState.VC_FILTERED;
else {
// Genotype level checks
callGenotype = callContext.getGenotype(callSample);
if (callGenotype.isNoCall()) callState = CallState.NO_CALL;
else if (callGenotype.isFiltered()) callState = CallState.GT_FILTERED;
else if ((callGenotype.getGQ() != -1) && (callGenotype.getGQ() < minGq)) callState = CallState.LOW_GQ;
else if ((callGenotype.getDP() != -1) && (callGenotype.getDP() < minDp)) callState = CallState.LOW_DP;
// Note. Genotype.isMixed means that it is called on one chromosome and NOT on the other
else if ((callGenotype.isMixed())) callState = CallState.NO_CALL;
}
// initialize the reference
String truthRef = (truthContext != null) ? truthContext.getReference().getBaseString() : null;
String callRef = (callContext != null) ? callContext.getReference().getBaseString() : null;
String truthAllele1 = null;
String truthAllele2 = null;
if (null == truthState) {
// Truth State not yet determined - will need to use truth genotypes below
if (truthGenotype.getAlleles().size() != 2) {
throw new IllegalStateException("Genotype for Variant Context: " + truthContext + " does not have exactly 2 alleles");
}
truthAllele1 = truthGenotype.getAllele(0).getBaseString();
truthAllele2 = truthGenotype.getAllele(1).getBaseString();
}
String callAllele1 = null;
String callAllele2 = null;
if (null == callState) {
if (callGenotype.getAlleles().size() != 2) {
throw new IllegalStateException("Genotype for Variant Context: " + callContext + " does not have exactly 2 alleles");
}
callAllele1 = callGenotype.getAllele(0).getBaseString();
callAllele2 = callGenotype.getAllele(1).getBaseString();
}
if ((truthRef != null && callRef != null) && (!truthRef.equals(callRef))) {
// This is for dealing with indel conditions, where we can have truth being TCAA*/T, call being TCAACAA*/TCAA (*=ref)
// So, we want to verify that both refs start with the shorter substring of the two
// and then we want to pad the shorter's ref and alleles, so that TCAA*/T becomes TCAACAA*/TCAA (i.e. tacking on the CAA)
if (truthRef.length() < callRef.length()) {
// Truth reference is shorter than call reference
final String suffix = getStringSuffix(callRef, truthRef, "Ref alleles mismatch between: " + truthContext + " and " + callContext);
truthRef = truthRef + suffix;
if (null == truthState) {
truthAllele1 = truthGenotype.getAllele(0).getBaseString() + suffix;
truthAllele2 = truthGenotype.getAllele(1).getBaseString() + suffix;
}
}
else if (truthRef.length() > callRef.length()) {
// call reference is shorter than truth:
final String suffix = getStringSuffix(truthRef, callRef, "Ref alleles mismatch between: " + truthContext + " and " + callContext);