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 CRAM container offset calculation #1167

Merged
merged 1 commit into from
Aug 6, 2018

Conversation

tomwhite
Copy link
Contributor

Description

Fixes a bug from #1129, and added a test to check for the error (which fails without the fix).

Checklist

  • Code compiles correctly
  • New tests covering changes and new functionality
  • All tests passing
  • Extended the README / documentation, if necessary
  • Is not backward compatible (breaks binary or source compatibility)

@tomwhite
Copy link
Contributor Author

@cmnbroad, could you take a look when you get a chance please?

I found the bug when I was testing large CRAM files with Disq.

@codecov-io
Copy link

codecov-io commented Jul 17, 2018

Codecov Report

Merging #1167 into master will increase coverage by 0.018%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##              master     #1167       +/-   ##
===============================================
+ Coverage     68.354%   68.372%   +0.018%     
- Complexity      8003      8005        +2     
===============================================
  Files            541       541               
  Lines          32674     32674               
  Branches        5531      5531               
===============================================
+ Hits           22334     22340        +6     
+ Misses          8115      8111        -4     
+ Partials        2225      2223        -2
Impacted Files Coverage Δ Complexity Δ
...jdk/samtools/cram/build/CramContainerIterator.java 84.848% <100%> (ø) 10 <0> (ø) ⬇️
...samtools/util/AsyncBlockCompressedInputStream.java 76% <0%> (+4%) 13% <0%> (+1%) ⬆️
...sjdk/samtools/util/Md5CalculatingOutputStream.java 76.923% <0%> (+7.692%) 9% <0%> (+1%) ⬆️

Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

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

Change looks good, one request to tighten up the test.

// try to read a container from the offset to check it's correct
try (SeekableFileStream seekableFileStream = new SeekableFileStream(cramFile)) {
seekableFileStream.seek(headerOnlyContainer.offset);
ContainerIO.readContainer(actualHeader.getVersion(), seekableFileStream);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since you have the actual fullContainer that corresponds to the container you're reading from the stream, can you grab the return value from readContainer and add a couple of equality asserts, maybe for alignmentStart, alignmentSpan, nofRecords, checksum, to verify the container is intact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@tomwhite tomwhite force-pushed the cram-container-offset-fix branch from c4eb34d to 55c7113 Compare July 19, 2018 08:34
Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

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

Thanks, looks good. Needs @lbergelson to merge.

@yfarjoun
Copy link
Contributor

yfarjoun commented Aug 6, 2018

I hope I'm not stepping on any toes as I merge this....

@yfarjoun yfarjoun merged commit 5168c79 into samtools:master Aug 6, 2018
@tomwhite
Copy link
Contributor Author

tomwhite commented Aug 7, 2018

Thanks @yfarjoun!

@tomwhite tomwhite deleted the cram-container-offset-fix branch September 6, 2018 10:28
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.

4 participants