This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to read vcf.bgz or vcf.gz in python using PyVcf?

When I try to do simply like this:

vcf_reader = vcf.Reader(open("input.vcf.gz", 'r')) vcf_writer = vcf.Writer(open('input.vcf.gz', 'w'), vcf_reader)

there is an error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

pyvcf vcf python

1 answer

I haven't tried it by I think you should use the filename parameter:

vcf_reader = vcf.Reader(filename='input.vcf.gz')

Log in to answer this question.