Problems when parsing VCF file with Python
1
0
Entering edit mode
6.9 years ago
joreamayarom ▴ 140

I'm trying to create sliding windows of a vcf file using Egglib Egglib's slider method for VcfParser class. My code and the error looks like this:

import egglib
vcf = egglib.io.VcfParser("20000.vcf")
for ret in vcf:
      print ret #Check if the file was loaded. Everything is OK up to here.

#Make windows of ten bp
for window in vcf.slider(10,10):
       for ret in window:
                 print ret
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: slider() takes at least 4 arguments (3 given)

#I tried the same providing all the parameters as described in link above to no avail

for window in vcf.slider(10,10,stop=None, size_as_sites=False, step_as_sites=False, max_missing=0, fill=False, first_sample=0, last_sample=None, flat=False):
       for ret in window:                                                                                                                   
          print ret 
Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
TypeError: slider() got an unexpected keyword argument 'size_as_sites'

It looks like I'm accidentally calling the homonym method for Align, but I'm not an expert with this library. Am I missing something here? Is this a bug?

python vcf • 1.7k views
ADD COMMENT
0
Entering edit mode
6.9 years ago

It is not a homonym, it is a method of the class. Hence it cannot be accidentally called, it belongs to the instance.

The problem is most likely that you are shadowing a different object called the same way. I would suggest to write small, simple independent scripts rather than using the python command prompt to type in commands (that's what the error above looks like). It is not a good habit to have. It only ends up polluting the namespace with hard to debug errors. Small, standalone scripts are much easier to debug, share and discuss when it comes to errors. See also what this does:

print type(vcf)

Use a tool like PyCharm, then you can put the cursor on vcf.slider and press Command-B and it will take you to the actual definition of the code that gets executed.

ADD COMMENT
1
Entering edit mode

Thanks for your suggestion. I've contacted the people maintaining the program and they told me there's likely a bug involved. I'll update the question when a solution is ready.

ADD REPLY

Login before adding your answer.

Traffic: 1893 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