- Define a "Hit" (based on some cutoff- evalue, score etc)
- Get output in the tabular format
- Count number of hits per query — it is usually given in the header; if you want to look for some selected hits (based on some cutoff, then you can parse the file and find out)
Example file (header):
# BLASTN 2.2.27+
# Query: TCONS_00036712 gene=XLOC_017996
# Database: ../nt_db/nt
# Fields: query id, subject id, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
# 1014 hits found
If you want to parse the header to look for number of hits then you can run this command in the terminal (if you have awk — there by default in linux and other unix based systems. For windows install gnuwin32).
awk -v OFS="\t" '/^# Query/{q=$3 FS $4} /^# .* hits found/{h[q]=$2} END{for(i in h){print i,h[i]}}' blastoutput.txt
To get the number of hits for a given criterion (for e.g. I just defined bitscore [12th column] to be >400)
awk -F "\t" '!/^#/ && $12>400{a[$1]++} END{for(i in a){print i,a[i]}}' blastoutput.txt