Question: Why is PyVCF's Reader failing to read VCF file?
0
gravatar for wrel2015
3.6 years ago by
wrel20150
wrel20150 wrote:

Hello,

does anyone know why I am getting this error with the Reader function in the PyVCF module. The VCF file used here was read normally using a Perl VCF module.

>>> fl = vcf.Reader(filename='sample.vcf.gz', compressed=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".local/lib/python2.7/site-packages/PyVCF-0.6.7-py2.7-linux-x86_64.egg/vcf/parser.py", line 288, in __init__
    self._parse_metainfo()
  File ".local/lib/python2.7/site-packages/PyVCF-0.6.7-py2.7-linux-x86_64.egg/vcf/parser.py", line 309, in _parse_metainfo
    key, val = parser.read_info(line)
  File ".local/lib/python2.7/site-packages/PyVCF-0.6.7-py2.7-linux-x86_64.egg/vcf/parser.py", line 123, in read_info
    "One of the INFO lines is malformed: %s" % info_string)
SyntaxError: One of the INFO lines is malformed: ##INFO=<ID=SOMATIC,Number=.,Description="Somatic status of existing variant (from ensembl VEP) associated with the most severe consequence in the CQ field">

 

Many thanks.

 

snp software error • 1.9k views
ADD COMMENTlink modified 3.6 years ago by brian@codenhance.com70 • written 3.6 years ago by wrel20150
1
gravatar for brian@codenhance.com
3.6 years ago by
United States
brian@codenhance.com70 wrote:

Hi there,

I think PyVCF requires that you add a "Type" descriptor to your INFO lines. The valid options are "Integer", "Float", "Flag", "Character", or "String".

So if you change the line above to look like this:

##INFO=<ID=SOMATIC,Number=.,Type=String,Description="Somatic status of existing variant (from ensembl VEP) associated with the most severe consequence in the CQ field">

It should work. Hope that helps!

ADD COMMENTlink written 3.6 years ago by brian@codenhance.com70

thank you Brian. This did quite down the INFO error but now there is a "contig lines malformation" error, I guess because the contig lines come after the INFO lines in the header and they too lack a "Type=String" attribute.

Is there an option in the Reader function of PyVCF that forces header lines to be read as strings or avoids me having to manipulate the header lines to make it work? For example if I were to read thousands of VCF files.

ADD REPLYlink written 3.6 years ago by wrel20150
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: 2056 users visited in the last hour