This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Blast - How to get the no hits result on table output?

Hi,

I use BLASTN with python.

I prefer -outfmt 6 parameter (table output) because its easy to read on python but the problem is, this output format doesn't gives result if there is no match.

for example:

blastn -query genes.fasta -db genome.fasta -outfmt 6

this command gives me 3 result with matches

gene1   NC_000913.3     100.000 2030    0       0       1       2030    1       
gene2   NC_000913.3     99.444  1260    7       0       1       1260    2101    
gene3   NC_000913.3     100.000 1190    0       0       1       1190    3431   

blastn -query genes.fasta -db genome.fasta -outfmt 7

this command gives me 4 result with 3 match and 1 zero match.

# BLASTN 2.11.0+
# Query: nogene
# Database: genome1.fasta
# 0 hits found
# BLASTN 2.11.0+
# Query: gene1
# Database: genome1.fasta
# Fields: query acc.ver, subject acc.ver, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
# 1 hits found
gene1   NC_000913.3     100.000 2030    0       0       1       2030    1       2030    0.0     3749
# BLASTN 2.11.0+
# Query: gene2
# Database: genome1.fasta
# Fields: query acc.ver, subject acc.ver, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
# 1 hits found
gene2   NC_000913.3     99.444  1260    7       0       1       1260    2101    3360    0.0     2289
# BLASTN 2.11.0+
# Query: gene3
# Database: genome1.fasta
# Fields: query acc.ver, subject acc.ver, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
# 1 hits found
gene3   NC_000913.3     100.000 1190    0       0       1       1190    3431    4620    0.0     2198
# BLAST processed 4 queries
blast blastn python

As you discovered you have to use -outfmt 7 if you want to get queries with no hits listed in output.

If there isn't any easiest way to do it, I will try to parse -outfmt 7.

Either you parse the -outfmt 7 output or then you parse the headers (up until first space I think) from your query file and comm -3 with the first column of your -outfmt 6 output. IMO the latter is "easier"

0 answers

No answers yet.

Log in to answer this question.