<p>I've reproduced the issue. The solution is to simply set <code>-max_target_seqs</code> to whatever number of hits you want. E.g. <code>-max_target_seqs 1000</code> gives 1000 and so on ... The problem  is specific to the <code>-outfmt</code> option and not default searches.</p>
<p><strong>blastn version</strong>  I'm using v2.12.0, Feb  8 2022</p>
<hr />
<p><strong>Proof</strong>
My database contains around 260000 fasta sequences.</p>
<pre><code>makeblastdb -in mystuff.aln.0.fa   -parse_seqids -blastdb_version 5  -out test.db -title &quot;test&quot; -dbtype nucl 
blastn -query query.fas -db test.db -evalue 1e-6 -num_threads 4 -out blasthits.txt
</code></pre>
<p>Then <code>wc blasthits.txt</code></p>
<blockquote>
<p>&gt;5000 hits</p>
</blockquote>
<p>If we now use <code>-outfmt 6</code>, but remove the stringency of <code>-evalue 1e-6</code> then ...</p>
<pre><code>blastn -query query.fa -db test.db -outfmt 6 -num_threads 4 -out blasthits.txt
</code></pre>
<p>Now perform <code>wc blasthits.txt</code></p>
<blockquote>
<p>500</p>
</blockquote>
<p>So the OP is correct, I didn't know <code>-outfmt 6</code> restricts the output to 500.</p>
<p>If we now introduce the <code>max_target_seqs 1000</code> parameter, suggested by @Laura then,</p>
<pre><code>blastn -query query.fa -db test.db -outfmt 6 -max_target_seqs 1000 -num_threads 4 -out blasthits.txt
</code></pre>
<p>Then <code>wc blasthits.txt</code></p>
<blockquote>
<p>1000</p>
</blockquote>
<p>If its 550 <code>wc ...</code> is 550 etc...</p>
<p>Thats it. Note in my blasts I usually parallelise across 4 processes i.e. <code>-num_threads 4</code>.</p>

CC BY-SA 4.0
2023-05-17T15:13:20.260Z
Thank you very much, it worked!
K_081
CC BY-SA 4.0
2023-05-19T08:30:58.943Z
Thanks @KirtiKulanthaivel glad it worked and much appreciated.
M__
CC BY-SA 4.0
2023-05-16T14:22:50.287Z
2023-05-16T14:57:35.893Z
2023-05-16T14:57:35.893Z
M__
<p>I had created databases of different sets of metagenome datasets - one with 6 runs, other with 48 runs, another with 100 runs, etc using the accession list for each of these datasets and makeblastdb command. Since I wanted to check the abundance of one specific 16S rRNA gene sequence, I ran a blastn command using this 16S sequence (F7) as the query against each of the created databases with a txt file (F7_droughtS.txt, F7_Dy.txt, so on) as the output. Ideally I should have got differently sized files with different number of OTU matches. I did get different files since the SRR ids were different for each database, but the results did not go beyond 500 lines for any database search. Can anyone explain why this is so?</p>
<p>Following is the command I used for blastn of:
<code>sequence.fasta</code> against database <code>firstdb</code> :</p>
<pre><code>blastn -query sequence.fasta -db firstdb -outfmt 6 -out output1.txt
</code></pre>
<p>Also ran the following to know the default number of lines :
<code>blastn -help -max_target_seqs</code></p>
<p>Number of database sequences to show one-line descriptions for</p>
<blockquote>
<p>Not applicable for outfmt &gt; 4 Default = 500'     * Incompatible with:  max_target_seqs  -num_alignments &lt;Integer, &gt;=0&gt;    Number of database sequences to show alignments for    Default = 250' * Incompatible with: max_target_seqs</p>
</blockquote>

CC BY-SA 4.0
2023-05-09T08:54:05.397Z
I suggest you have a look at the settings for the blast version you are using. These can usually be accessed with 'blastn -help'. In particular, '-max_target_seqs' may be of interest.
Laura
CC BY-SA 4.0
2023-05-09T10:43:00.193Z
Please [edit] your question and i) remove the images of the files, that isn't telling us anything. You can show us the output of `wc -l  file` to show the number of lines. ii) show us the _exact_ commands you used. You are probably using a version of blast that shows the top 500 hits by default, but we need to know what blast you use and what exact commands you ran in order to help.
terdon
CC BY-SA 4.0
2023-05-14T14:55:39.917Z
@Laura, Thank you for your suggestions. When I did run the code provided by you, this is what I got : 

Number of database sequences to show one-line descriptions for
   Not applicable for outfmt > 4
   Default = `500'
    * Incompatible with:  max_target_seqs
 -num_alignments <Integer, >=0>
   Number of database sequences to show alignments for
   Default = `250'
* Incompatible with:  max_target_seqs

How can I change these settings?
K_081
CC BY-SA 4.0
2023-05-16T17:40:56.860Z
Not an expert on 16S, but is BLAST really the correct tool for this(?) Maybe one of these tool suites like QIME
Chris_Rands
CC BY-SA 4.0
2023-05-16T19:26:06.510Z
QIIME is an interesting suggestion. Here I'd say BLAST - although there are performance issues - offset parallelising. BLAST is a known approach to scoop all the genetic diversity for a given locus and 16S is a taxonomic goldstandard. This isn't the analysis - the analytics are in the next step, but how you've prepped the data for the next step needs to be understood and be solid. There are a lot of other approaches but blast has flexibility e.g. to shift tblastn .. etc ... and its why I like it.
M__
CC BY-SA 4.0
2023-05-16T19:31:51.960Z
Personally, IMO "modulisation" custom data pipelines in general, i.e. loads of steps - gives more control and each developer specialises on their component rather than try and do everything at once. The latter is the QIIME approach, but its an interesting debate.
M__
<phylogenetics><phylogeny><metagenome><blastn><makeblastdb>
Blast output file only shows 500 lines -outfmt 6
# Blast output file only shows 500 lines -outfmt 6

(Asked by: username_0 on 2023-05-09)

I had created databases of different sets of metagenome datasets - one with 6 runs, other with 48 runs, another with 100 runs, etc using the accession list for each of these datasets and makeblastdb command. Since I wanted to check the abundance of one specific 16S rRNA gene sequence, I ran a blastn command using this 16S sequence (F7) as the query against each of the created databases with a txt file (F7_droughtS.txt, F7_Dy.txt, so on) as the output. Ideally I should have got differently sized files with different number of OTU matches. I did get different files since the SRR ids were different for each database, but the results did not go beyond 500 lines for any database search. Can anyone explain why this is so?
Following is the command I used for blastn of:
sequence.fasta against database firstdb :
blastn -query sequence.fasta -db firstdb -outfmt 6 -out output1.txt

Also ran the following to know the default number of lines :
blastn -help -max_target_seqs
Number of database sequences to show one-line descriptions for

Not applicable for outfmt > 4 Default = 500'     * Incompatible with:  max_target_seqs  -num_alignments =0>    Number of database sequences to show alignments for    Default = 250' * Incompatible with: max_target_seqs

**Tags:** phylogenetics, phylogeny, metagenome, blastn, makeblastdb
> **Comments:**
> **username_1**: I suggest you have a look at the settings for the blast version you are using. These can usually be accessed with 'blastn -help'. In particular, '-max_target_seqs' may be of interest.  
> **username_2**: Please [edit] your question and i) remove the images of the files, that isn't telling us anything. You can show us the output of `wc -l  file` to show the number of lines. ii) show us the _exact_ commands you used. You are probably using a version of blast that shows the top 500 hits by default, but we need to know what blast you use and what exact commands you ran in order to help.  
> **username_0**: @Laura, Thank you for your suggestions. When I did run the code provided by you, this is what I got :   Number of database sequences to show one-line descriptions for    Not applicable for outfmt > 4    Default = `500'     * Incompatible with:  max_target_seqs  -num_alignments <Integer, >=0>    Number of database sequences to show alignments for    Default = `250' * Incompatible with:  max_target_seqs  How can I change these settings?  
> **username_3**: Not an expert on 16S, but is BLAST really the correct tool for this(?) Maybe one of these tool suites like QIME  
> **username_4**: QIIME is an interesting suggestion. Here I'd say BLAST - although there are performance issues - offset parallelising. BLAST is a known approach to scoop all the genetic diversity for a given locus and 16S is a taxonomic goldstandard. This isn't the analysis - the analytics are in the next step, but how you've prepped the data for the next step needs to be understood and be solid. There are a lot of other approaches but blast has flexibility e.g. to shift tblastn .. etc ... and its why I like it.  
> **username_4**: Personally, IMO "modulisation" custom data pipelines in general, i.e. loads of steps - gives more control and each developer specialises on their component rather than try and do everything at once. The latter is the QIIME approach, but its an interesting debate.  

---

## 1 answers

### Answer by username_4 on 2023-05-16. Score: 1 | Accepted answer

I've reproduced the issue. The solution is to simply set -max_target_seqs to whatever number of hits you want. E.g. -max_target_seqs 1000 gives 1000 and so on ... The problem  is specific to the -outfmt option and not default searches.
blastn version  I'm using v2.12.0, Feb  8 2022

Proof
My database contains around 260000 fasta sequences.
makeblastdb -in mystuff.aln.0.fa   -parse_seqids -blastdb_version 5  -out test.db -title "test" -dbtype nucl 
blastn -query query.fas -db test.db -evalue 1e-6 -num_threads 4 -out blasthits.txt

Then wc blasthits.txt

>5000 hits

If we now use -outfmt 6, but remove the stringency of -evalue 1e-6 then ...
blastn -query query.fa -db test.db -outfmt 6 -num_threads 4 -out blasthits.txt

Now perform wc blasthits.txt

500

So the OP is correct, I didn't know -outfmt 6 restricts the output to 500.
If we now introduce the max_target_seqs 1000 parameter, suggested by @Laura then,
blastn -query query.fa -db test.db -outfmt 6 -max_target_seqs 1000 -num_threads 4 -out blasthits.txt

Then wc blasthits.txt

1000

If its 550 wc ... is 550 etc...
Thats it. Note in my blasts I usually parallelise across 4 processes i.e. -num_threads 4.

> **Comments:**
> **username_0**: Thank you very much, it worked!  
> **username_4**: Thanks @KirtiKulanthaivel glad it worked and much appreciated.  

---

