Attribute Error Using Biopython Bio.Searchio.Convert
1
0
Entering edit mode
11.0 years ago

Hello, writing a script in Python using Biopython modules that will convert Blast XML output to Tabular form. I get an attribute error as follows:

Traceback (most recent call last):
File "C:\Python33\myscripts\Working\Convert_Blast_XML_to_Tabular.py", line 4, in 
<module>
from Bio import SearchIO

File "C:\Python33\lib\site-packages\Bio\SearchIO\__init__.py", line 213, in <module>
BiopythonExperimentalWarning)

File "C:\Python33\lib\idlelib\PyShell.py", line 60, in idle_showwarning
file.write(warnings.formatwarning(message, category, filename, lineno, line=line))

AttributeError: 'NoneType' object has no attribute 'write'

Not sure where the problem arises, but I don't think it's my code:

from Bio import SearchIO
import os

blast_out= "some_path"
parsed_out="some_path"

os.chdir(blast_out)
all_files = os.listdir(blast_out)

for single_file in all_files:
    print ("Current file is: " + single_file)

    #define handles
    in_file = single_file
    in_fmt = 'blast-xml'
    out_file = parsed_out + single_file + '.tab'
    out_fmt = 'blast-tab'
    out_kwarg = {'comments': True}

    SearchIO.convert(in_file, in_fmt, out_file, out_fmt, out_kwargs=out_kwarg)

print ("\nFinished Parsing File.\n")
python biopython • 3.0k views
ADD COMMENT
0
Entering edit mode

This seems to be an issue with pyshell, rather than biopython. Can you use python without it (I've never used python on Windows)?

Edit: It's likely that this is the bug in question and it's been open for a while. I expect this will take a while to get resolved since so few people actually try to program in python on Windows. In reality, I suspect that just modifying PyShell.py to change stderr might fix this.

ADD REPLY
0
Entering edit mode

Yes, I can use python without using any Biopython modules. Any suggestions to modify PyShell.py?

ADD REPLY
0
Entering edit mode

I actually wanted to know if you can use biopython (or python in general) without using the Idle interface on windows. For editing PyShell.py, you might just have a look at this thread on stackoverflow.

ADD REPLY
0
Entering edit mode
11.0 years ago

Thank you both for your help. Instead of editing PyShell.py, I've added the following code as a prefix to my own:

    import warnings
with warnings.catch_warnings():
    warnings.simplefilter('ignore')
    from Bio import SearchIO

It didn't fix the root of the problem, but allowed the script to give the appropriate output. Thanks again.

ADD COMMENT

Login before adding your answer.

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