<p>I came across this thread while searching for a solution to a similar problem I was experiencing. I am inputting markers that are 20 basepairs in length as the query sequence and haven't been getting hits. As terdon mentioned in their excellent reply, setting word size to something smaller like 11 helps for these shorter query sequences.</p>
<p>I didn't get any results on my 20 bp query sequences when using blastn against the sunflower genome, but I got plenty when setting word size to 11. So, why does setting word size for blastn to 11 improve the results despite documentation stating that default word size is 11? Well it turns out that this is very misleading. <a href="https://www.ncbi.nlm.nih.gov/Class/MLACourse/Modules/BLAST/nucleotide_blast.html" rel="nofollow noreferrer">This webpage</a> explains that the default <strong>algorithm</strong> used in blastn is actually megablast, not blastn. The default word length for this default megablast algorithm is actually 28!</p>
<p>The documentation is quite unclear about this and many websites providing tutorials for blastn also seem to miss this key detail. Hope this helps anyone else who struggles with this!</p>

CC BY-SA 4.0
2023-09-05T16:33:39.660Z
Your hyperlink doesn't seem to be working any longer, but megablast vs blastn is a huge difference. Command line `-task blastn` or python `task="blastn"` will switch the algorithm.
ded
CC BY-SA 4.0
2023-01-26T21:43:04.243Z
2023-01-26T21:43:04.243Z
Brian
<p>There are three possible problems that come to mind.</p>
<ol>
<li><p>Masking</p>
<p>Blast will mask low complexity regions by default. Since your sequence is nothing but Gs, it is a safe bet that it is being masked, so no hits will be found for it.</p>
</li>
<li><p>Score/e-value thresholds</p>
<p>Another source of complication is that even if a match is found, that match will have very bad scores. Both the actual score of the alignment and the e-value will be very bad. Since this is such a simple sequence, it will always score badly.</p>
</li>
<li><p>Word-size</p>
<p>The way blast works is (simplifying a bit) by finding a match for N residues (the word size) and then extending that match if extending increases the score. If your query sequence is shorter than the word size, no match will ever be found.</p>
</li>
</ol>
<p>With all that said, the specific problem in your case seems to be a combination of the word-size and masking. If you run your query setting the word-size to 11 and disabling masking, as shown below, you should get results.</p>
<pre><code>blastn -db A.fna -query B.fna -word_size 11 -dust no
</code></pre>
<p>That should return two hits (two because the word size is one less than the query size, so it can align perfectly at two locations):</p>
<pre><code>&gt; A
Length=64

 Score = 23.3 bits (12),  Expect = 5e-05
 Identities = 12/12 (100%), Gaps = 0/12 (0%)
 Strand=Plus/Plus

Query  1   GGGGGGGGGGGG  12
           ||||||||||||
Sbjct  11  GGGGGGGGGGGG  22

 Score = 23.3 bits (12),  Expect = 5e-05
 Identities = 12/12 (100%), Gaps = 0/12 (0%)
 Strand=Plus/Plus

Query  1   GGGGGGGGGGGG  12
           ||||||||||||
Sbjct  12  GGGGGGGGGGGG  23
</code></pre>
<p>Note that the default word size for BLASTn searches is usually 11. I don't know why the blast+ version (2.2.31+) I have on my Ubuntu machine didn't use that as a default. The manual says it should. But I got no hits when I didn't explicitly set the word size to 11.</p>

CC BY-SA 4.0
2018-05-03T17:24:58.660Z
that makes a lot of sense (i was not familiar with the concept/term of masking) thanks (:
Paul
CC BY-SA 4.0
2018-05-03T17:06:31.820Z
2018-05-03T17:06:31.820Z
2020-06-18T08:30:41.743Z
terdon
<p>I am currently exploring the BLAST program, just for testing purpose i generated two FASTA files, containing two genes A and B, such that B is just a motif of repeated 'G's that occurs in A.</p>

<p>file A.fna:</p>

<pre><code>&gt;A
ACCAACAGACGGGGGGGGGGGGGAGAAAACCGGCCCCCGCAGGGACGCCACCCAGAGGGAAGGG
</code></pre>

<p>file B.fna:</p>

<pre><code>&gt;B
GGGGGGGGGGGG
</code></pre>

<p>So by my understanding BLAST should find the local alignment of B in A easily? But the program returns 'No hits found'? Maybe I am doing something wrong here?</p>

<p>I executed the following:</p>

<pre><code>makeblastdb -in A.fna -dbtype 'nucl'
makeblastdb -in B.fna -dbtype 'nucl'
blastn -db A.fna -query B.fna
</code></pre>

<p>output of blastn:</p>

<pre><code>BLASTN 2.7.1+


Reference: Zheng Zhang, Scott Schwartz, Lukas Wagner, and Webb Miller (2000), "A greedy algorithm for aligning DNA sequences", J Comput Biol 2000; 7(1-2):203-14.



Database: A.fna
           1 sequences; 64 total letters



Query= B

Length=12


***** No hits found *****



Lambda      K        H
    1.33    0.621     1.12 

Gapped Lambda      K        H
    1.28    0.460    0.850 

Effective search space used: 480


  Database: A.fna
    Posted date:  May 3, 2018  5:17 PM   Number of letters in database: 64   Number of sequences in database:  1



Matrix: blastn matrix 1 -2 Gap Penalties: Existence: 0, Extension: 2.5
</code></pre>

<p>Thanks for any suggestions (:</p>

CC BY-SA 4.0
2018-05-03T16:10:09.623Z
I'm not sure but could it be that there are too many gaps and then it doesn't match it. BLAST doesn't just search for a sequence inside another one, but looks for similarities between sequences, and these two sequences are not similar (even if one contains the other)
llrs
CC BY-SA 4.0
2018-05-03T16:22:51.293Z
But is that not exactly what BLAST is supposed to do (*local* alignment)? There is a perfect local alignment (without any gaps). In terms of global alignment the two sequences are very different (and gap penalties are huge), but here we are talking about local alignments !?
Paul
CC BY-SA 4.0
2018-05-03T17:19:33.243Z
Yes, it should, glad we have terdon to answer the question
llrs
<phylogenetics><blast>
BLAST(n): No hits found
# BLAST(n): No hits found

(Asked by: username_0 on 2018-05-03)

I am currently exploring the BLAST program, just for testing purpose i generated two FASTA files, containing two genes A and B, such that B is just a motif of repeated 'G's that occurs in A.
file A.fna:
>A
ACCAACAGACGGGGGGGGGGGGGAGAAAACCGGCCCCCGCAGGGACGCCACCCAGAGGGAAGGG

file B.fna:
>B
GGGGGGGGGGGG

So by my understanding BLAST should find the local alignment of B in A easily? But the program returns 'No hits found'? Maybe I am doing something wrong here?
I executed the following:
makeblastdb -in A.fna -dbtype 'nucl'
makeblastdb -in B.fna -dbtype 'nucl'
blastn -db A.fna -query B.fna

output of blastn:
BLASTN 2.7.1+


Reference: Zheng Zhang, Scott Schwartz, Lukas Wagner, and Webb Miller (2000), "A greedy algorithm for aligning DNA sequences", J Comput Biol 2000; 7(1-2):203-14.



Database: A.fna
           1 sequences; 64 total letters



Query= B

Length=12


***** No hits found *****



Lambda      K        H
    1.33    0.621     1.12 

Gapped Lambda      K        H
    1.28    0.460    0.850 

Effective search space used: 480


  Database: A.fna
    Posted date:  May 3, 2018  5:17 PM   Number of letters in database: 64   Number of sequences in database:  1



Matrix: blastn matrix 1 -2 Gap Penalties: Existence: 0, Extension: 2.5

Thanks for any suggestions (:

**Tags:** phylogenetics, blast
> **Comments:**
> **username_1**: I'm not sure but could it be that there are too many gaps and then it doesn't match it. BLAST doesn't just search for a sequence inside another one, but looks for similarities between sequences, and these two sequences are not similar (even if one contains the other)  
> **username_0**: But is that not exactly what BLAST is supposed to do (*local* alignment)? There is a perfect local alignment (without any gaps). In terms of global alignment the two sequences are very different (and gap penalties are huge), but here we are talking about local alignments !?  
> **username_1**: Yes, it should, glad we have terdon to answer the question  

---

## 2 answers

### Answer by username_4 on 2018-05-03. Score: 13 | Accepted answer

There are three possible problems that come to mind.

Masking
Blast will mask low complexity regions by default. Since your sequence is nothing but Gs, it is a safe bet that it is being masked, so no hits will be found for it.

Score/e-value thresholds
Another source of complication is that even if a match is found, that match will have very bad scores. Both the actual score of the alignment and the e-value will be very bad. Since this is such a simple sequence, it will always score badly.

Word-size
The way blast works is (simplifying a bit) by finding a match for N residues (the word size) and then extending that match if extending increases the score. If your query sequence is shorter than the word size, no match will ever be found.


With all that said, the specific problem in your case seems to be a combination of the word-size and masking. If you run your query setting the word-size to 11 and disabling masking, as shown below, you should get results.
blastn -db A.fna -query B.fna -word_size 11 -dust no

That should return two hits (two because the word size is one less than the query size, so it can align perfectly at two locations):
> A
Length=64

 Score = 23.3 bits (12),  Expect = 5e-05
 Identities = 12/12 (100%), Gaps = 0/12 (0%)
 Strand=Plus/Plus

Query  1   GGGGGGGGGGGG  12
           ||||||||||||
Sbjct  11  GGGGGGGGGGGG  22

 Score = 23.3 bits (12),  Expect = 5e-05
 Identities = 12/12 (100%), Gaps = 0/12 (0%)
 Strand=Plus/Plus

Query  1   GGGGGGGGGGGG  12
           ||||||||||||
Sbjct  12  GGGGGGGGGGGG  23

Note that the default word size for BLASTn searches is usually 11. I don't know why the blast+ version (2.2.31+) I have on my Ubuntu machine didn't use that as a default. The manual says it should. But I got no hits when I didn't explicitly set the word size to 11.

> **Comments:**
> **username_0**: that makes a lot of sense (i was not familiar with the concept/term of masking) thanks (:  

---

### Answer by username_2 on 2023-01-26. Score: 3

I came across this thread while searching for a solution to a similar problem I was experiencing. I am inputting markers that are 20 basepairs in length as the query sequence and haven't been getting hits. As terdon mentioned in their excellent reply, setting word size to something smaller like 11 helps for these shorter query sequences.

I didn't get any results on my 20 bp query sequences when using blastn against the sunflower genome, but I got plenty when setting word size to 11. So, why does setting word size for blastn to 11 improve the results despite documentation stating that default word size is 11? Well it turns out that this is very misleading. [This webpage](https://www.ncbi.nlm.nih.gov/Class/MLACourse/Modules/BLAST/nucleotide_blast.html) explains that the default **algorithm** used in blastn is actually megablast, not blastn. The default word length for this default megablast algorithm is actually 28!

The documentation is quite unclear about this and many websites providing tutorials for blastn also seem to miss this key detail. Hope this helps anyone else who struggles with this!

> **Comments:**
> **username_3**: Your hyperlink doesn't seem to be working any longer, but megablast vs blastn is a huge difference. Command line `-task blastn` or python `task="blastn"` will switch the algorithm.  

---

