bcftools
bcftools copied to clipboard
bcftools reheader Incomplete File if Output Same as Input
It sounds like it should be possible to modify file in-place:
bcftools reheader [OPTIONS] file.vcf.gz Modify header of VCF/BCF files, change sample names.
However, if -o path is same as input file path, the result is a corrupted file. Why not an error message or work as expected?
I am reluctant to add checks like that, certain awareness is required from users when working with command line tools.
Few notes if such check should be added:
- this affects and would be added to all bcftools commands
-
realpath()would have to be used to prevent common variations (eg./file.bcfvsfile.bcf) or symlinks - this would still not catch hard links
- this would still not catch cases where multiple commands are piped together
- probably best is to check for the existence of output file. However, this breaks backward compatibility and will not be liked by those who want to overwrite existing files without being asked
So although seemingly simple, it's not an easy decision to make.