Skip to content

Conversation

@daviesrob
Copy link
Member

This didn't work in the past because update_from_fai() opened, read the header from, and then closed the input file, preventing the reheader_* functions from accessing the rest of the file contents when the input is a stream. As all the reheader_* functions read the header into a kstring, it's possible to make streaming work by passing this kstring into update_from_fai() and adjusting it to work directly on that copy of the data.

As update_from_fai() no longer needs to write a temporary file, args_t::rm_tmpfile and args_t::tmp_prefix can be removed. The -T option is ignored as it's no longer needed, but is still accepted for compatibility. The init_tmp_prefix() function is still used by some other bcftools subcommands, so is left in place for now.

Fixes #2088

This didn't work in the past because update_from_fai() opened,
read the header from, and then closed the input file, preventing
the reheader_* functions from accessing the rest of the file
contents when the input is a stream.  As all the reheader_*
functions read the header into a kstring, it's possible to make
streaming work by passing this kstring into update_from_fai() and
adjusting it to work directly on that copy of the data.

As update_from_fai() no longer needs to write a temporary file,
args_t::rm_tmpfile and args_t::tmp_prefix can be removed.  The -T
option is ignored as it's no longer needed, but is still accepted
for compatibility.  The init_tmp_prefix() function is still used
by some other bcftools subcommands, so is left in place for now.
@pd3 pd3 merged commit a1bedee into samtools:develop Mar 21, 2024
@clintval
Copy link

Thank you @daviesrob 🙏 !

@daviesrob daviesrob deleted the streaming_reheader branch August 7, 2024 11:22
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.

bcftools reheader to support stdin?

3 participants