-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring a confusing method in GATKVariantContextUtils #8690
base: master
Are you sure you want to change the base?
Conversation
baking a null check into isInformative since it's always used with the check separating all cases out and reducing nesting of ifs
@jamesemery @droazen I found that method pretty confusing so I did som rearrangments. The method I extracted probably needs a new name. |
final GenotypeAssignmentMethod assignmentMethod = GATKVariantContextUtils.isInformative(genotypeLikelihoods) | ||
? GenotypeAssignmentMethod.USE_PLS_TO_ASSIGN | ||
: GenotypeAssignmentMethod.SET_TO_NO_CALL; | ||
GATKVariantContextUtils.makeGenotypeCall(g.getPloidy(), gb, assignmentMethod, genotypeLikelihoods, allelesToUse, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it clear here that the only difference here is the assignment method.
@@ -308,66 +308,71 @@ public static void makeGenotypeCall(final int ploidy, | |||
final List<Allele> allelesToUse, | |||
final List<Allele> originalGT, | |||
final GenotypePriorCalculator gpc) { | |||
if(originalGT == null && assignmentMethod == GenotypeAssignmentMethod.BEST_MATCH_TO_ORIGINAL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this special case down into the BEST_MATCH_TO_ORIGINAL
gb.alleles(Collections.nCopies(ploidy, ref)); | ||
gb.PL(new int[genotypeLikelihoods.length]).log10PError(0); | ||
} | ||
case USE_PLS_TO_ASSIGN -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I separated these PREFER_PLS and USE_PLS_TO_ASSIGN so it's clear where they're different and pulled out the shared setUsingPls. That could probably use a better name.
} | ||
case USE_POSTERIORS_ANNOTATION, DO_NOT_ASSIGN_GENOTYPES-> { } // do nothing in these cases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case DO_NOT_ASSIGN_GENOTYPES previously just fell through, now it's at least listed.
} | ||
} | ||
|
||
private static void setUsingPls(final int ploidy, final GenotypeBuilder gb, final double[] genotypeLikelihoods, final List<Allele> allelesToUse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naaame meeeee
baking a null check into isInformative since it's always used with the check
separating all cases out and reducing nesting of ifs