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

Zero len array #1674

Merged
merged 3 commits into from
Aug 3, 2023
Merged

Zero len array #1674

merged 3 commits into from
Aug 3, 2023

Conversation

gileshall
Copy link
Collaborator

PR #1194 removed a number of Array.getLength(value) == 0 checks when setting B-array tagged fields, as such empty tagged field values had recently been made explicitly valid in SAM/BAM/CRAM files.

Unfortunately the existing such check in setUnsignedArrayAttribute() was omitted from that PR and has now caused the issue raised in samtools/hts-specs#728. Whatever additional problems might (but probably don't) exist elsewhere in the HTSJDK code for zero-length ML tags, this check for a generic zero-length array was incorrect and should be removed. A test case for setUnsignedArrayAttribute() has also been added.

In grepping for other candidates, I noticed one other potentially incorrect looking Array.getLength invocation.

This was in Slice::setAttribute(), which appears to set an optional tag in a Slice header. There are currently no such tags defined, so the question is somewhat moot but — as a separate commit for your consideration — I have also removed that check. (As there are no such tags currently defined, there are no test cases for these fields to which a test exercising this change could be added.)

--

Updated jmarshall pull request to remove unused Slice::setAttribute() methods.

jmarshall and others added 3 commits June 13, 2023 21:37
This function was omitted from PR #1194. Zero-length 'B' arrays
are valid, so remove this check too and add a test case.
Slices' optional tags follow the rules for BAM tagged fields, so
zero-length 'B' arrays are valid. Slice tags are currently unused,
so the question is somewhat moot and there are no test cases.
@gileshall gileshall requested a review from droazen August 3, 2023 17:01
@droazen droazen requested review from lbergelson and removed request for droazen August 3, 2023 17:53
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.

@lbergelson lbergelson merged commit d486d53 into master Aug 3, 2023
3 of 4 checks passed
@lbergelson lbergelson deleted the zero-len-array branch August 3, 2023 18:32
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.

3 participants