This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Trouble with BLAST using Biopython

I have been using Biopython to make scripts to run sequences through BLAST. I'm using the command:

 NCBIWWW.qblast()

Here is the beginning of most of my scripts:

import sys, os
from Bio import SeqIO, Entrez, SearchIO
from Bio.Blast import NCBIWWW, NCBIXML
from ftplib import FTP
from urllib.error import HTTPError

fasta_string = open(sys.argv[1]).read()
result_handle = NCBIWWW.qblast("blastn", "nt", fasta_string, hitlist_size=10)

save_file = open("my_blast.xml", "w")
save_file.write(result_handle.read())
save_file.close()
result_handle.close()

I couple months ago I had no problem running these scripts, now none of them will run but I will receive no error from the script. It will just look like its running but get suck at the above BLAST command. Is anyone else having a similar issue? If so were you able to fix it?? Thanks so much for the help!!

python ncbi blast

Can you post more snippets of your script?

Edited the original question!

You get something in your terminal if you add

print(result_handle.read())

?

I added this to my code and only got this in terminal:

ValueError: I/O operation on closed file

Where did you add the line, it has to be before the result_handle.close() call is made.

Consider reinstalling or updating BioPython? I can't tell you why its suddently stopped working for you, because that code works for me. (Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34), BioPython v1.70)

Has anything about your network (or your local infrastructure) changed? Seems like it could be a network issue.

I recall moving from http to https somewhere in the past although I think more than a few months ago. Maybe an update will help

Hello tpaisie!

We believe that this post does not fit the main topic of this site.

Fixed problem.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

1 answer

I got the script to work finally! Some set up must have been off on my computer or with my biopython!

Great, if you ever figure out exactly what it was, please do post up :)

BTW, once a post has answers, there's no need to close it, so I've reopened this accordingly. To provide closure to the post, you can accept you own post as the thread answer by clicking the check mark.

Log in to answer this question.