This is a test version of Biostars. For the public version, visit https://www.biostars.org.
list all records in a vcf file?

Is it possible to use tabix or a similar tool to list all records (chrom and pos) in a tabix indexed block gzipped vcf file or do I need to loop over the file to acquire this information? Thanks.

zcat seems to be faster than bcftools:

zcat file.vcf.gz | grep -v ^# | cut -f-2
bcftools query -f '%CHROM\t%POS\n' file.vcf.gz
bgzf vcf tabix

1 answer

vcftools should do the trick:

vcftools --gzvcf vcfFile.vcf.gz --stdout

If the above doesn't work/give you a VCF output, try adding a --recode at the end.

Thanks a lot RamRS. How is that different from looping over the file with zcat? I think both are equally slow, no?

They very well might be, but unfortunately this is the only technique I know :(

Please do update your post with a better technique if you come across one - I'm sure many of us would benefit from it!

I sure will update my post RamRS, if I come across a better solution. I have asked a few coworkers and hopefully they will get back to me by Monday with a silver bullet solution. Thanks for your suggestion.

You're most welcome :)

The VCFTools Perl might be a bit more optimized for TABIX-ed VCF GZs, might wanna check that out too!

Log in to answer this question.