How to read a vcf.gz file in Python?

Viewed 204

I have a file in the vcf.gz format (e.g. file_name.vcf.gz) - and I need to read it somehow in Python.

I understood that first I have to decompress it and then to read it. I found this solution, but it doesn't work for me unfortunately. Even for the first line (bgzip file_name.vcf or tabix file_name.vcf.gz) it says SyntaxError: invalid syntax.

Could you help me please?

1 Answers

Both cyvcf and pyvcf can read vcf files, but cyvcf is much faster and is more actively maintained.

Related