A handy bash alias for compressing and indexing vcf files

Wouter De Coster

bioinformatics

100 Words · 27 Seconds

2019-05-22 09:15


I often have a ton of vcf files, which I would like to compress using bgzip and index using tabix, which is necessary for many downstream steps such as bcftools concat. I grew tired of always typing the same command, so I wrote the following bash alias, which uses gnu parallel and is part of my .bash_aliases file.

alias vcfzip=“ls *.vcf | parallel –bar ‘bgzip {} && tabix {}.gz’”

When I’m in a directory with files that need to be compressed I can simply execute vcfzip and all files will get compressed and indexed, together with a friendly progress bar.