<p>Hurray, the solution seems already to be implemented in the new BLAST database format (v5), which is usable with blast+ versions >= 2.8.0.</p>

<p>It is possible to specify an exclusion as well as inclusion list of taxon ids, which, however, have to be on species level.</p>

<p>Species level taxon ids can be obtained from higher level taxon ids using the script get_species_taxids.sh, e.g.: <code>get_species_taxids.sh -n Enterobacterales</code></p>

<p>See docs here: <a href="https://ftp.ncbi.nlm.nih.gov/blast/db/v5/blastdbv5.pdf" rel="nofollow noreferrer">https://ftp.ncbi.nlm.nih.gov/blast/db/v5/blastdbv5.pdf</a></p>

<p>Edit:<br>
For creating taxon ID lists locally from the NCBI taxonomy files, the program <a href="https://github.com/pmenzel/taxonomy-tools#subtree" rel="nofollow noreferrer">subtree</a> can be used. See example therein for compiling a list of taxon IDs from environmental or unclassified taxa.</p>

CC BY-SA 4.0
2020-01-15T17:01:51.273Z
Sorry to bother you, but how did you manage to work with get_species_taxids.sh? Because I installed edirect on linux, but won't work with the script.
Sofia
CC BY-SA 4.0
2019-04-05T08:32:06.467Z
2019-08-08T14:25:35.870Z
2019-08-08T14:25:35.870Z
Peter Menzel
<p>I am looking for a solution to exlude certain entries when searching a local blast nt database (with blastn), specifically the sequences from uncultured / environmental samples, ideally using their taxon ids.
This should ideally replicate the results from the BLAST web interface, when checking the option "<em>Exclude Uncultured/environmental sample sequences</em>", see screenshot below.</p>

<p>Three approaches that I am aware of so far are:</p>

<p>(1) grep taxon IDs for any taxa with "uncultured" or "environmental" in their scientific name from names.dmp and fetch the GIs belonging to these taxa using the E-utils. Then use the -negative_gilist parameter for blastn. However, GIs are discontinued for future records, so this method should be replaced by Acc.Ver identifiers.</p>

<p>(2) locally format the blast database after prepocessing the nt file by myself and exclude records belonging to the taxa list as obtained in (1).</p>

<p>(3) Postprocess the blast output and remove the relevant lines, but this approach might remove a lot of alignments, whereas (1) and (2) would always generate the desired number of output alignments.</p>

<p>So, I am looking for other suggestions, preferably without preprocessing the nt file.
Ideally, one would like to have a -negative_taxalist option for blastn, which would resemble what is possible on the NCBI BLAST web interface, where one can exclude taxa, see screenshot below.</p>

<p><a href="https://i.sstatic.net/BLwXE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BLwXE.png" alt="NCBI BLAST interface"></a></p>

<p>Thanks!</p>

<blast>
taxon exclude list for searching local blast database using blastn
# taxon exclude list for searching local blast database using blastn

(Asked by: username_0 on 2019-04-04)

I am looking for a solution to exlude certain entries when searching a local blast nt database (with blastn), specifically the sequences from uncultured / environmental samples, ideally using their taxon ids.
This should ideally replicate the results from the BLAST web interface, when checking the option "*Exclude Uncultured/environmental sample sequences*", see screenshot below.

Three approaches that I am aware of so far are:

(1) grep taxon IDs for any taxa with "uncultured" or "environmental" in their scientific name from names.dmp and fetch the GIs belonging to these taxa using the E-utils. Then use the -negative\_gilist parameter for blastn. However, GIs are discontinued for future records, so this method should be replaced by Acc.Ver identifiers.

(2) locally format the blast database after prepocessing the nt file by myself and exclude records belonging to the taxa list as obtained in (1).

(3) Postprocess the blast output and remove the relevant lines, but this approach might remove a lot of alignments, whereas (1) and (2) would always generate the desired number of output alignments.

So, I am looking for other suggestions, preferably without preprocessing the nt file.
Ideally, one would like to have a -negative\_taxalist option for blastn, which would resemble what is possible on the NCBI BLAST web interface, where one can exclude taxa, see screenshot below.

[![NCBI BLAST interface](https://i.sstatic.net/BLwXE.png)](https://i.sstatic.net/BLwXE.png)

Thanks!

**Tags:** blast

---

## 1 answers

### Answer by username_0 on 2019-04-05. Score: 1 | Accepted answer

Hurray, the solution seems already to be implemented in the new BLAST database format (v5), which is usable with blast+ versions >= 2.8.0.

It is possible to specify an exclusion as well as inclusion list of taxon ids, which, however, have to be on species level.

Species level taxon ids can be obtained from higher level taxon ids using the script get\_species\_taxids.sh, e.g.: `get_species_taxids.sh -n Enterobacterales`

See docs here: <https://ftp.ncbi.nlm.nih.gov/blast/db/v5/blastdbv5.pdf>

Edit:  
For creating taxon ID lists locally from the NCBI taxonomy files, the program [subtree](https://github.com/pmenzel/taxonomy-tools#subtree) can be used. See example therein for compiling a list of taxon IDs from environmental or unclassified taxa.

> **Comments:**
> **username_1**: Sorry to bother you, but how did you manage to work with get_species_taxids.sh? Because I installed edirect on linux, but won't work with the script.  

---

