Skip to content
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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lbergelson
Copy link
Member

baking a null check into isInformative since it's always used with the check
separating all cases out and reducing nesting of ifs

baking a null check into isInformative since it's always used with the check
separating all cases out and reducing nesting of ifs
@lbergelson
Copy link
Member Author

@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);
Copy link
Member Author

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) {
Copy link
Member Author

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 -> {
Copy link
Member Author

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
Copy link
Member Author

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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naaame meeeee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant