text: user2766: 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 (:
  
  user16834: 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 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!
  
  user298: 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.
  
original_text: 2766: <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>
   16834: <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>
   298: <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>
  