Question: Attribute Error Using Biopython Bio.Searchio.Convert
0
gravatar for charles.bridges
6.0 years ago by
charles.bridges70 wrote:

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 convert • 1.8k views
ADD COMMENTlink modified 6.0 years ago • written 6.0 years ago by charles.bridges70

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 REPLYlink modified 6.0 years ago • written 6.0 years ago by Devon Ryan92k

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

ADD REPLYlink written 6.0 years ago by charles.bridges70

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 REPLYlink written 6.0 years ago by Devon Ryan92k
0
gravatar for charles.bridges
6.0 years ago by
charles.bridges70 wrote:

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 COMMENTlink written 6.0 years ago by charles.bridges70
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: 873 users visited in the last hour