samtools / bcftools

This is the official development repository for BCFtools. See installation instructions and other documentation here http://samtools.github.io/bcftools/howtos/install.html
http://samtools.github.io/bcftools/
Other
634 stars 241 forks source link

Allow bcftools reheader --fai to read its input file from a stream #2129

Closed daviesrob closed 3 months ago

daviesrob commented 3 months ago

This didn't work in the past because update_fromfai() 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

clintval commented 3 months ago

Thank you @daviesrob 🙏 !