Dear Biostars folk,

I have been trying to come up with an efficient way to return all the NON-hits from a blastn query. Basically, I need to blast all reads in an Illumina library against one another, and only find the reads in set A that have not hit in B. Although I have a solution, it seems to be really slow, and I wonder if you could help me out. Here's what I did so far:

    makeblastdb -in ${B} -dbtype nucl
    blastn -query ${A} -db ${B} > blast_results.dat
    cat blast_results.dat \
      | grep 'No hits' -B 6 \
      | grep 'Query' \
      | cut -d '=' -f2 \
      | cut -d ' ' -f2 \
      > unique_read_ids.dat
    cat unique_read_ids.dat \
      | while read line; do sed -n "/${line}/,/>/p" $query \
      | sed '$d'; done \
      > result.fn

Now... this totally works, but it takes about a week to finish, although the blastn-part only take 1-2 days. So that last bit, where I fish out all the non-hits, it probably not so efficient. 

Is there any way to let blastn return NON-hits, instead of all queries / all hits? If so, how does that work? I've tried setting something up with the e-values, but it always seems to be a minimal value...

Thanks for your time!
For anyone returning to this in the future, there's a biopython tutorial on doing exactly this, in a much more efficient way: https://biopython.org/wiki/Retrieve_nonmatching_blast_queries