Question: How to read vcf file in python?
0
gravatar for ja4123
8 months ago by
ja41230
ja41230 wrote:

When I try to do simply like this:

import vcf
vcf_reader = vcf.Reader(filename="in.vcf.gz")

there is an error:

AttributeError: partially initialized module 'vcf' has no attribute 'Reader' (most likely due to a circular import)

But vcf module has that attribute .. Kindly help.

reader python vcf • 2.1k views
ADD COMMENTlink modified 8 months ago by onestop_data260 • written 8 months ago by ja41230

I always read it by pandas (after removing the heads).

ADD REPLYlink written 8 months ago by shoujun.gu310

personally, I just use GATK VariantsToTable to convert it to a .tsv first. Its much easier to parse this way. Unless you wanted something from the header? Another option might to be convert to another tabular format such as .maf

ADD REPLYlink written 8 months ago by steve2.6k

also it sounds like your installation of pyvcf is messed up. I would consider trying the version in conda; https://anaconda.org/bioconda/pyvcf

ADD REPLYlink written 8 months ago by steve2.6k
1
gravatar for onestop_data
8 months ago by
onestop_data260
onestop_data260 wrote:

Try Pysam . You can easily pip install it (pip install pysam)

ADD COMMENTlink modified 8 months ago • written 8 months ago by onestop_data260
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 825 users visited in the last hour