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 sam_hdr_dup to cope with long refs. #983

Merged
merged 1 commit into from
Nov 20, 2019

Conversation

daviesrob
Copy link
Member

This is a simplified version of the sam_hdr_dup fix from PR #976 split out into its own pull request.

If the source header has not been parsed yet (i.e. sam_hdr_t::hrecs is NULL) it just copies any entries in sam_hdr_t::sdict. If it has been parsed, sam_hdr_t::sdict entries are added in sam_hdr_update_target_arrays where necessary.

sam_hdr_update_target_arrays will now also remove sam_hdr_t::sdict entries if they are no longer needed. This fixes a bug where dangling pointers could be left in sdict if any target names have been removed.

Adds some sam_hdr_dup tests in test/sam.c check_big_ref().

The h->sdict hash is used to track references that are > 4Gb in size.
The dup code didn't copy this.  This manifested itself as CRAM SQ
headers being truncated (read SAM hdr, dup, write as CRAM hdr).

Fix by making sam_hdr_dup copy h0->sdict entries for non-parsed
headers; and by making sam_hdr_update_target_arrays() update
bh->sdict for parsed ones.

Co-Authored-By: Rob Davies <[email protected]>
Co-Authored-By: James Bonfield <[email protected]>
@jkbonfield jkbonfield merged commit 9279d76 into samtools:develop Nov 20, 2019
@daviesrob daviesrob deleted the sam_hdr_dup2 branch November 25, 2019 09:16
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