Exact model code cleanup
-- Fixed up code when fixing a bug detected by aggressive contracts in GenotypesContext.
This commit is contained in:
parent
2c501364b8
commit
1561af22af
|
|
@ -42,6 +42,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
|
||||||
private final static double MAX_LOG10_ERROR_TO_STOP_EARLY = 6; // we want the calculation to be accurate to 1 / 10^6
|
private final static double MAX_LOG10_ERROR_TO_STOP_EARLY = 6; // we want the calculation to be accurate to 1 / 10^6
|
||||||
private final boolean SIMPLE_GREEDY_GENOTYPER = false;
|
private final boolean SIMPLE_GREEDY_GENOTYPER = false;
|
||||||
private final static double SUM_GL_THRESH_NOCALL = -0.001; // if sum(gl) is bigger than this threshold, we treat GL's as non-informative and will force a no-call.
|
private final static double SUM_GL_THRESH_NOCALL = -0.001; // if sum(gl) is bigger than this threshold, we treat GL's as non-informative and will force a no-call.
|
||||||
|
private final List<Allele> NO_CALL_ALLELES = Arrays.asList(Allele.NO_CALL, Allele.NO_CALL);
|
||||||
|
|
||||||
protected ExactAFCalculationModel(UnifiedArgumentCollection UAC, int N, Logger logger, PrintStream verboseWriter) {
|
protected ExactAFCalculationModel(UnifiedArgumentCollection UAC, int N, Logger logger, PrintStream verboseWriter) {
|
||||||
super(UAC, N, logger, verboseWriter);
|
super(UAC, N, logger, verboseWriter);
|
||||||
|
|
@ -338,8 +339,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GenotypesContext calls = GenotypesContext.create();
|
final GenotypesContext calls = GenotypesContext.create();
|
||||||
|
|
||||||
int startIdx = AFofMaxLikelihood;
|
int startIdx = AFofMaxLikelihood;
|
||||||
for (int k = sampleIdx; k > 0; k--) {
|
for (int k = sampleIdx; k > 0; k--) {
|
||||||
int bestGTguess;
|
int bestGTguess;
|
||||||
|
|
@ -353,6 +353,7 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
|
||||||
|
|
||||||
double[] likelihoods = g.getLikelihoods().getAsVector();
|
double[] likelihoods = g.getLikelihoods().getAsVector();
|
||||||
|
|
||||||
|
if (MathUtils.sum(likelihoods) <= SUM_GL_THRESH_NOCALL) {
|
||||||
if (SIMPLE_GREEDY_GENOTYPER || !vc.isBiallelic()) {
|
if (SIMPLE_GREEDY_GENOTYPER || !vc.isBiallelic()) {
|
||||||
bestGTguess = Utils.findIndexOfMaxEntry(likelihoods);
|
bestGTguess = Utils.findIndexOfMaxEntry(likelihoods);
|
||||||
}
|
}
|
||||||
|
|
@ -390,28 +391,13 @@ public class ExactAFCalculationModel extends AlleleFrequencyCalculationModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
final double qual = GenotypeLikelihoods.getQualFromLikelihoods(bestGTguess, likelihoods);
|
final double qual = GenotypeLikelihoods.getQualFromLikelihoods(bestGTguess, likelihoods);
|
||||||
//System.out.println(myAlleles.toString());
|
|
||||||
calls.add(new Genotype(sample, myAlleles, qual, null, g.getAttributes(), false));
|
calls.add(new Genotype(sample, myAlleles, qual, null, g.getAttributes(), false));
|
||||||
|
} else {
|
||||||
|
final double qual = Genotype.NO_LOG10_PERROR;
|
||||||
|
calls.add(new Genotype(sample, NO_CALL_ALLELES, qual, null, g.getAttributes(), false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( final Genotype genotype : GLs.iterateInSampleNameOrder() ) {
|
|
||||||
if ( !genotype.hasLikelihoods() )
|
|
||||||
continue;
|
|
||||||
Genotype g = GLs.get(genotype.getSampleName());
|
|
||||||
|
|
||||||
double[] likelihoods = genotype.getLikelihoods().getAsVector();
|
|
||||||
|
|
||||||
if (MathUtils.sum(likelihoods) <= SUM_GL_THRESH_NOCALL)
|
|
||||||
continue; // regular likelihoods
|
|
||||||
|
|
||||||
ArrayList<Allele> myAlleles = new ArrayList<Allele>();
|
|
||||||
|
|
||||||
double qual = Genotype.NO_LOG10_PERROR;
|
|
||||||
myAlleles.add(Allele.NO_CALL);
|
|
||||||
myAlleles.add(Allele.NO_CALL);
|
|
||||||
//System.out.println(myAlleles.toString());
|
|
||||||
calls.add(new Genotype(genotype.getSampleName(), myAlleles, qual, null, g.getAttributes(), false));
|
|
||||||
}
|
|
||||||
return calls;
|
return calls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue