3
$\begingroup$

I am trying to search the NCBI non-redundant database for sequences similar to a few other (~40) sequences that I already have.

So I've tried running blastn remotely, and looping through multiple queries. I've tried it both as a job (via slurm) and from the command line.

In addition, for every query, I am trying to run 3 searches with slightly different parameters (in WebBlast, I noticed that I recover more sequences of interest this way).

I am trying to dump the output data in a single file (stuff like duplicates can be sorted out later).

This is my code:

for i in /directory/*.fa;do #this is the directory containing the queries
j=${i#"/directory/"}
k=${j%".fa"} #getting a short version of the name for the log file
echo "$k" >> "log.log"
blastn -query "$i" -db "nt" -remote -entrez_query 700:1000[slen] -perc_identity 94 -outfmt "6 sacc sseqid sseq evalue bitscore length" >> "results.tsv"
blastn -query "$i" -db "nt" -remote -entrez_query 1000:1400[slen] -perc_identity 94 -outfmt "6 sacc sseqid sseq evalue bitscore length" >> "results.tsv"
blastn -query "$i" -db "nt" -remote -perc_identity 94 -outfmt "6 sacc sseqid sseq evalue bitscore length" >> "results.tsv"
done

However, it...doesn't seem to work? Either only the first search for the first query is completed, and then the code does nothing else, or nothing happens. (in a rare case, the first two searches worked) There seems to be no clear distinction between 'it works a tiny bit' and 'it doesn't work at all', which leads me to think it might be something outside the code, e.g. connection issues.

Has anyone faced this before, and would you know how to fix it?

Update I tried to run a single search as well. As well as adding the waiting period. Right now it doesn't work (same issue, no error message, just sort of appearing to run without results). In the link that Scot provided below, from the NCBI, it was mentioned 'We will move searches of users who submit more than 100 searches in a 24 hour period to a slower queue, or, in extreme cases, will block the requests.' I haven't run >100 searches yesterday (was planning to before I knew this, but that's a different issue).

I think I'll limit the searches as recommended and try to run it from a different computer later on.

$\endgroup$
5
  • 1
    $\begingroup$ Hi @Laura could you have one final try using sleep 60? The other idea is to set up a cron job and run it over night, I wouldn't try and manually overcome the challenge. $\endgroup$
    – M__
    Oct 7, 2022 at 11:59
  • $\begingroup$ @M__ I tried. First search works as normal (finishes in a couple of minutes). The next are...again, very very slow. I left the job running for a bit, and it's taken 2h for now while only on the 4th search. $\endgroup$
    – Laura
    Oct 7, 2022 at 14:28
  • $\begingroup$ Hi @Laura - depending on your network environment (perhaps on a University network), and the details of how NCBI BLAST throttling works, you may be throttled as a group rather than as an individual. Trying this from a different network may help if this is the case. $\endgroup$
    – Scot
    Oct 7, 2022 at 18:54
  • 2
    $\begingroup$ And it is beyond the scope of your question, but if you are desiring to run hundreds of BLASTs eventually, I'd look into downloading the BLAST executable and the nt database, and running the alignments locally. nt is not a small database, so this may be best done using slurm on your cluster, but if you can limit the alignments to a taxonomic segment of nt, you may be able to do this locally using just that taxonomic slice of nt. $\endgroup$
    – Scot
    Oct 7, 2022 at 19:02
  • $\begingroup$ Answered in the post $\endgroup$
    – M__
    Oct 8, 2022 at 0:03

2 Answers 2

2
$\begingroup$

I gave it a whirl using a random bit of SARS-CoV-2

blastn -query out.fa -db "nt" -remote  -outfmt "6 sacc sseqid sseq evalue bitscore length" >> "results.tsv"

blastn -query out.fa -db "nt" -remote -perc_identity 94 -outfmt "6 sacc sseqid sseq evalue bitscore length" >> "results2.tsv"

Both gave a 500 line output - the limit of the blast specified.

One possibility is to place a sleep 10 line between each blastn command (3 additional lines).

The rationale is specifications NCBI set:

Do not contact the server more often than once every 10 seconds. Do not poll for any single RID more often than once a minute. Use the URL parameter email and tool, so that the NCBI can contact you if there is a problem. Run scripts weekends or between 9 pm and 5 am Eastern time on weekdays if more than 50 searches will be submitted.


The suggestions haven't worked, so I'd recommend trying sleep 60 between each blastncommand on the basis this might be an issue with RID. If that fails the fall back is to run the job overnight US time via cron tab, which I'll post the code if it is required. Thus,

Run scripts weekends or between 9 pm and 5 am Eastern time on weekdays if more than 50 searches will be submitted.

The final thing to add is that it is a fairly long job so connectivity might be an issue. If this was the case then it might also be resolved by running the script overnight in the OPs timezone, i.e. via cron


sleep 60 works but is very slow.

  • Agreed one option is to download the database and perform the Blast locally.
  • Alternative use mmseqs2
  • You could perform the Blast on the Cloud, like GCP (much faster).
  • Personally I would look at performing over night runs when the network was not in use.
$\endgroup$
1
  • $\begingroup$ FYI @scot posted first ... similar ideas but credit to them. $\endgroup$
    – M__
    Oct 7, 2022 at 3:04
2
$\begingroup$

This is likely a throttling issue - see here for some details, specifically the one about contacting the NCBI server more than once every 10 seconds.

You may be able to submit a multiFASTA of all your queries to get around this issue, rather than individual FASTA sequences, or alternatively, add in a sleep 10 command between your BLAST commands and at the end of each for loop iteration to throttle the requests.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.