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 error that occurs when encoding a value greater than 32767 with ‘B, S’ data type in encoding alignment in encoding alignment. #264

Merged
merged 1 commit into from Sep 13, 2022

Conversation

matsutomo81
Copy link
Contributor

@matsutomo81 matsutomo81 commented Sep 5, 2022

In encoding alignment options, encoding values greater than 32767 with the 'B, S' data type causes an error.

For example, encoding the following alignment would result in the following error message. Note that the alignment option has the value of '65535' for 'B, S' type.
q006 0 ref 10 60 16M * 0 0 AAAAGGGGTTTTCCCC * XS:B:S,0,32767,65535

; Execution error (NumberFormatException) at java.lang.Short/parseShort (Short.java:139).
; Value out of range. Value:"65535" Radix:10

The reason for error is as follows.
According to BAM format specification, the value of 'B, S' type are encoded with uint16_t, but the current code was processing with Short/parseShort. Therefore, when encoding values greater than 32767, Short/parseShort returns an error.

This PR solves this problem by removing Short/parseShortand using lsb/write-ushort. This PR also adds tests to convert SAM/BAM file that contains the alignments with 'B, S' type data.

@codecov
Copy link

codecov bot commented Sep 5, 2022

Codecov Report

Merging #264 (fa167d3) into master (c7cd8c4) will increase coverage by 0.15%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #264      +/-   ##
==========================================
+ Coverage   88.71%   88.87%   +0.15%     
==========================================
  Files          78       78              
  Lines        6389     6389              
  Branches      442      442              
==========================================
+ Hits         5668     5678      +10     
+ Misses        279      269      -10     
  Partials      442      442              
Impacted Files Coverage Δ
src/cljam/io/bam/encoder.clj 75.67% <0.00%> (+5.40%) ⬆️
src/cljam/io/util/lsb.clj 85.08% <0.00%> (+3.31%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@matsutomo81 matsutomo81 marked this pull request as ready for review September 6, 2022 01:49
@matsutomo81 matsutomo81 requested a review from a team as a code owner September 6, 2022 01:49
@matsutomo81 matsutomo81 requested review from r6eve and removed request for a team September 6, 2022 01:49
@matsutomo81 matsutomo81 changed the title Fix error that occurs when encoding a value greater than 32767 with ‘B, S’ data type. Fix error that occurs when encoding a value greater than 32767 with ‘B, S’ data type in encoding alignment in encoding alignment. Sep 7, 2022
Copy link
Contributor

@r6eve r6eve left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for fixing that.

Copy link
Member

@alumi alumi left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this!
It seems that the BAM file you committed (test-resources/bam/include-BS-type-option.bam) doesn't contain B:S options. Would you replace it with a one generated by samtools view -bh test-resources/sam/include-BS-type-option.sam?

@matsutomo81
Copy link
Contributor Author

matsutomo81 commented Sep 13, 2022

@alumi
Thank you for finding my mistake!
The data in the test BAM file was incorrect and has been fixed.

Copy link
Member

@alumi alumi left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks!

@alumi alumi merged commit ccfae4e into chrovis:master Sep 13, 2022
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

3 participants