This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error when using blastn in biopython

I am trying to use NcbiblastnCommandline from biopython and catching an error:

Bio.Application.ApplicationError: Non-zero return code 1 from 'blastn -out output.csv -outfmt 6 qstart qend length sstrand -query original.fasta -evalue 1000 -word_size 4 -subject original.fasta -strand plus -dust no -perc_identity 100.0', message 'USAGE'

There is no error when I execute the same command from terminal, google search give me nothing about this error and message "USAGE" absolutely non-informative for me. What can cause such error and how can I fix it?

biopython blastn

I think 6 qstart qend length sstrand needs to be in quotation marks.

In my script it is in quotation marks.

cline = NcbiblastnCommandline(query="original.fasta", subject="original.fasta", out="output.csv", outfmt="6 qstart qend length sstrand", dust="no", word_size=4, evalue=1000, strand="plus", perc_identity=100.0)

What does it appear like in cline? It needs to be in " options " in the actual command line.

Yes, you right. Thank you. The problem was in quotation marks, but now I am a little confused because yesterday I was writing another script and I was using the same way to customize my output table and all worked without quotation marks in command line. And it works now. In yesterday's script. I checked.

Was that a blast command script? In this case blast needs that option to be in quotes.

Now I understand, but in my yesterday's script outfmt="6 qseqid sseqid qcovs" works perfectly, whereas today outfmt="6 qstart qend length sstrand" is not working but outfmt="'6 qstart qend length sstrand'" is working.

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.