Why is PyVCF's Reader failing to read VCF file?
1
0
Entering edit mode
9.4 years ago
wrel2015 • 0

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

software-error snp pyvcf • 3.9k views
ADD COMMENT
1
Entering edit mode
9.4 years ago

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 COMMENT
0
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 1737 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6