I'm trying to run a local BLAST with biopython using Bio.Blast.Applications. However, when running the below code:
from Bio.Blast.Applications import NcbiblastpCommandline
result = r"C:\Users\Uzytkownik\Desktop\tests\result.xml"
q = r"C:\Users\Uzytkownik\Desktop\tests\fastas\my_example2.faa"
database = r"C:\Users\Uzytkownik\Desktop\tests\my_examplemultif.faa"
blastp_cline = NcbiblastpCommandline(query = q, db = database, evalue = 0.001, outfmt=5, out = result)
stdout, stderr = blastp_cline()
I receive an error stating:
ApplicationError: Non-zero return code 1 from 'blastp -out C:\\Users\\Uzytkownik\\Desktop\\tests\\result.xml -outfmt 5 -query C:\\Users\\Uzytkownik\\Desktop\\tests\\fastas\\my_example2.faa -db C:\\Users\\Uzytkownik\\Desktop\\tests\\my_examplemultif.faa -evalue 0.001', message "'blastp' is not recognized as an internal or external command,"
I've tried running this with subprocess and os., but got the same error every time.
When I run the query through the command line everything works fine (I'm using blast 2.9.0+), so I'm really not sure what the issue is. Would be gratefull for any help!
First find the location where your blastp
executble is installed and give that as argument to NcbiblastpCommandline
.
from Bio.Blast.Applications import NcbiblastpCommandline
blastp_path = r"C:\path\to\blastp.exe"
result = r"C:\Users\Uzytkownik\Desktop\tests\result.xml"
q = r"C:\Users\Uzytkownik\Desktop\tests\fastas\my_example2.faa"
database = r"C:\Users\Uzytkownik\Desktop\tests\my_examplemultif.faa"
blastp_cline = NcbiblastpCommandline(cmd=blastp_path, query=q, db=database, evalue=0.001, outfmt=5, out=result)
If you now do print(blastp_cline)
it should print out the full command that is going to be run. Doublecheck that this works by copy/pasting this output and running it from the commandline. If that works, then
stdout, stderr = blastp_cline()
should work too.