Allow empty file in `bcf_sr_set_regions`
I have some code that looks something like:
bcftools view foo.bcf -R <(tabix bar.bim.bgz chr${chrom}:${start}-${stop} | cut -f 1,4)
where I loop over chrom start and end and proceed in chunks along the genome, pulling parts out a plink-formatted bim file that I've indexed with tabix. The problem is if tabix returns an empty file, bcftools errors out because bcf_sr_regions_init returns a null pointer when the region file is empty, and bcf_sr_set_regions returns -1. I would argue that the correct behavior for bcftools view some_vcf.vcf -R empty_file should be to return the same thing as bcftools view -h some_vcf.vcf, i.e it should return a file with just the header. I think the easiest way to do that is to change bcf_sr_set_regions, so that's why my issue is here. I'm happy to create a pull request if there's agreement that this is a reasonable thing to do.
I agree that'd be a reasonable behavior, happy to accept a pull request. Thank you for raising the issue.