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

fix code duplication in ReadPosRankSumTest and its allele-specific version #2657

Merged
merged 1 commit into from
Aug 31, 2017

Conversation

davidbenjamin
Copy link
Contributor

Closes #1882.

Normally I assign the author of the issue for this kind of stuff, but Adam is no longer with us. @ldgauthier would you mind looking and/or suggesting anything else on your wish list for the annotations code?

@codecov-io
Copy link

codecov-io commented May 4, 2017

Codecov Report

Merging #2657 into master will decrease coverage by 0.003%.
The diff coverage is 100%.

@@              Coverage Diff               @@
##              master    #2657       +/-   ##
==============================================
- Coverage     80.453%   80.45%   -0.003%     
+ Complexity     17522    17521        -1     
==============================================
  Files           1173     1173               
  Lines          63415    63406        -9     
  Branches        9879     9875        -4     
==============================================
- Hits           51019    51010        -9     
  Misses          8447     8447               
  Partials        3949     3949
Impacted Files Coverage Δ Complexity Δ
...ellbender/tools/walkers/annotator/RankSumTest.java 94.595% <100%> (-0.142%) 18 <0> (ø)
...er/tools/walkers/annotator/ReadPosRankSumTest.java 100% <100%> (ø) 11 <4> (+1) ⬆️
...nnotator/allelespecific/AS_ReadPosRankSumTest.java 100% <100%> (ø) 7 <1> (-3) ⬇️
...ools/walkers/annotator/BaseQualityRankSumTest.java 100% <100%> (ø) 5 <1> (+1) ⬆️
...ator/allelespecific/AS_BaseQualityRankSumTest.java 100% <100%> (ø) 4 <1> (ø) ⬇️

@ldgauthier
Copy link
Contributor

ldgauthier commented May 4, 2017 via email

public class AS_ReadPosRankSumTest extends AS_RankSumTest implements AS_StandardAnnotation {

final ReadPosRankSumTest readPosRankSumTest = new ReadPosRankSumTest();
Copy link
Contributor

Choose a reason for hiding this comment

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

I really wanted this class to inherit from AS_RankSumTest and ReadPosRankSumTest, so I picked one and copied the code from the other. This is far more elegant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like the real way to do this is via a decorator that makes some annotation allele-specific, but I have no idea how to do that in Java.

Copy link
Contributor

@droazen droazen May 4, 2017

Choose a reason for hiding this comment

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

It looks to me like getElementForRead(), at least, could be made static (or rather, you could have getElementForRead() delegate to a static method). I suspect that isUsableRead() could be refactored to call into a static method as well. Then you wouldn't have to instantiate ReadPosRankSumTest like this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@droazen I couldn't figure out a way to beat code duplication for isUsableRead -- since you can't override static methods, every option was a lot more fuss than it was worth. I made getElementForRead delegate to a static method in order to avoid instantiating a ReadPosRankSumTest.

@ldgauthier ldgauthier self-assigned this May 4, 2017
@ldgauthier
Copy link
Contributor

Ha, this PR was much tinier than I expected -- feet are barely damp.

My "wishlist" would include a much bigger refactor because I made a mess in Java7 and didn't have the time to clean up (especially with generics) after we switched in Java8. I'm still tinkering with the rank sum tests though, so it's not worth tackling the refactor until those are good to go.

👍

@ldgauthier ldgauthier removed their assignment May 4, 2017
@droazen droazen self-assigned this May 5, 2017
@davidbenjamin
Copy link
Contributor Author

@droazen am I waiting for your approval?

@davidbenjamin
Copy link
Contributor Author

@droazen waiting for your thumbs to be directed toward the stars.

@davidbenjamin
Copy link
Contributor Author

@droazen Is it okay to merge this PR?

@droazen
Copy link
Contributor

droazen commented Jun 7, 2017

@davidbenjamin I'll have a look at this one later today.

@davidbenjamin
Copy link
Contributor Author

Rebased -- should still pass tests.

@ldgauthier
Copy link
Contributor

I think this is good to go, @droazen .

@davidbenjamin
Copy link
Contributor Author

@lbergelson do you think you could approve this while David is away?

@lbergelson
Copy link
Member

@davidbenjamin Sorry to get in your way, I see that this has been sitting forever. I know that @jamesemery is working on this same code right now. I'm going to pass this one to him so he can have a heads up about this change.

@lbergelson lbergelson assigned jamesemery and unassigned droazen Aug 30, 2017
@lbergelson
Copy link
Member

@jamesemery Could you take a look at this change.

Copy link
Collaborator

@jamesemery jamesemery left a comment

Choose a reason for hiding this comment

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

These changes look good, and the tests seem to enforce that this shouldn't have broken much. I'd say you are good to merge!

@davidbenjamin davidbenjamin merged commit f2e7030 into master Aug 31, 2017
@davidbenjamin davidbenjamin deleted the db_issue_1882 branch August 31, 2017 20:50
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.

6 participants