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

Fixed 1097 bug where GL field overrides PL field. #1098

Merged
merged 6 commits into from
Jun 6, 2018
Merged

Conversation

yfarjoun
Copy link
Contributor

@yfarjoun yfarjoun commented Mar 7, 2018

When GL and PL are inconsistent, and GL is "after" PL, the resulting genotype has the wrong PL value.

  • fixed bug
  • added test which failed prior to the change.

fixes #1097

…e inconsistent, and GL is "after" PL, the resulting genotype has the wrong PL value.

- added test which failed prior to the change.
@yfarjoun
Copy link
Contributor Author

yfarjoun commented Mar 7, 2018

to the reviewer: use ?w=1 as many lines are just whitespace changes (tabs->spaces)

Assert.assertEquals(new VCF3Codec().getTabixFormat(), TabixFormat.VCF);
}

private void assertIntArraysAreEqual(int[] v1, int[] v2) {
Copy link
Member

Choose a reason for hiding this comment

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

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 couldn't find that in the version that we have in htsjdk....I could rev TestNG I guess.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. I just didn't know in which version it was introduced...

@codecov-io
Copy link

codecov-io commented Mar 7, 2018

Codecov Report

Merging #1098 into master will increase coverage by 0.33%.
The diff coverage is 100%.

@@              Coverage Diff               @@
##              master     #1098      +/-   ##
==============================================
+ Coverage     66.185%   66.515%   +0.33%     
- Complexity      7636      7748     +112     
==============================================
  Files            535       535              
  Lines          32403     32743     +340     
  Branches        5513      5627     +114     
==============================================
+ Hits           21446     21779     +333     
- Misses          8792      8800       +8     
+ Partials        2165      2164       -1
Impacted Files Coverage Δ Complexity Δ
...main/java/htsjdk/variant/vcf/AbstractVCFCodec.java 73.292% <100%> (+0.083%) 90 <0> (+1) ⬆️
...java/htsjdk/variant/vcf/VCFCompoundHeaderLine.java 75.714% <0%> (+0.714%) 44% <0%> (+6%) ⬆️
...in/java/htsjdk/samtools/util/SamLocusIterator.java 92.553% <0%> (+1.249%) 29% <0%> (+7%) ⬆️
...rc/main/java/htsjdk/samtools/SamFileValidator.java 87.372% <0%> (+2.29%) 143% <0%> (+64%) ⬆️
...main/java/htsjdk/samtools/SAMRecordSetBuilder.java 92.814% <0%> (+3.603%) 83% <0%> (+18%) ⬆️
...tsjdk/variant/variantcontext/writer/VCFWriter.java 92.045% <0%> (+4.241%) 20% <0%> (+2%) ⬆️
src/main/java/htsjdk/samtools/BAMRecordCodec.java 88.889% <0%> (+4.353%) 28% <0%> (+13%) ⬆️
...sjdk/samtools/util/Md5CalculatingOutputStream.java 76.923% <0%> (+7.692%) 9% <0%> (+1%) ⬆️

- removed unneeded helper function
Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

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

@yfarjoun Thanks for the fix. I think we should probably expose a getter instead of call to make, although that might mean we need to expose getters for the other built in attributes for symmetry.

Should we be in the business of detecting gl /pl disagreement and warning about it? Or do we just not care because gl is deprecated?

gb.PL(GenotypeLikelihoods.fromGLField(genotypeValues.get(i)).getAsPLs());
// Do not overwrite PL with data from GL
if (!gb.make().hasPL()) {
gb.PL(GenotypeLikelihoods.fromGLField(genotypeValues.get(i)).getAsPLs());
Copy link
Member

Choose a reason for hiding this comment

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

@yfarjoun Thanks for fixing this. I don't love the call to make() in this if statement. It would be nice to avoid any extra allocations. It might be worth adding a getPL method to the builder in order to avoid having to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this were needed in production code, I'd agree with you, but given that I'm using it in a test, I hesitate to add this feature when it didn't seem to be needed thus far.

public void testGLnotOverridePL() {
VCFFileReader reader = new VCFFileReader(new File("src/test/resources/htsjdk/variant/test_withGLandPL.vcf"), false);
VariantContext variant = reader.iterator().next();
reader.close();
Copy link
Member

Choose a reason for hiding this comment

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

always better to do this in a try-with-resources instead of the manual call to close

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right...i just copied from above...changing in both places.

@yfarjoun
Copy link
Contributor Author

yfarjoun commented Mar 8, 2018

I don't want to be detecting PL/GL disagreements, but I think that overwriting the PL with a transformed GL is wrong...this is what I'm protecting against.

@yfarjoun
Copy link
Contributor Author

bump

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

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

@yfarjoun 👍 when tests pass

@lbergelson
Copy link
Member

@yfarjoun Push is failing because it's out of date, but PR is good, so I'm merging this. Thank you.

@lbergelson lbergelson merged commit 0d8e1c6 into master Jun 6, 2018
@lbergelson lbergelson deleted the yf_fix_1097_bug branch June 6, 2018 19:25
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.

getPL Returning Incorrect Values
4 participants