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

bcftools reheader Incomplete File if Output Same as Input #2140

Open
DarioS opened this issue Mar 26, 2024 · 1 comment
Open

bcftools reheader Incomplete File if Output Same as Input #2140

DarioS opened this issue Mar 26, 2024 · 1 comment

Comments

@DarioS
Copy link

DarioS commented Mar 26, 2024

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?

@pd3
Copy link
Member

pd3 commented Apr 27, 2024

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.bcf vs file.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.

@pd3 pd3 mentioned this issue Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants