This is a test version of Biostars. For the public version, visit https://www.biostars.org.
'blastp' is not recognized as an internal or external command using Bio.Blast.Applications

Hello!

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,"

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!

biopython blast

blastp is not available in your PATH. Since this appears to be windows you will need to amend PATH accordingly (or provide full path to the blastp executable).

idk if it can help, when I run blast inside python, I put (example with blastx):

from Bio.Blast.Applications import NcbiblastxCommandline

cline = NcbiblastxCommandline(query = query_file, db = database_file, out = query_file+'.blastx', 
outfmt = 6, word_size = 3, evalue = 0.00001, num_threads = threads)
stdout, stderr = clone()

my blast version: Translated Query-Protein Subject BLAST 2.9.0+

1 answer

Follow this BLAST+ to install BLAST+ on windows and adding it to the path should work.

from Bio.Blast.Applications import NcbiblastnCommandline

blastn = "C:/path_to_blast/blast-BLAST_VERSION+/bin/blastn"

cline = NcbiblastnCommandline(cmd = blastn,query='query.fasta', out='out.tab', outfmt=6, subject='subject.fasta') stdout, stderr = cline()

print("STDOUT: %s" % stdout)

print("STDERR: %s" % stderr)

Log in to answer this question.