Blast Command Line Applications User Manual: Last Updated: June 28, 2021
Blast Command Line Applications User Manual: Last Updated: June 28, 2021
NLM Citation: BLAST® Command Line Applications User Manual [Internet]. Bethesda (MD): National Center for Biotechnology
Information (US); 2008-.
iii
This manual documents the BLAST (Basic Local Alignment Search Tool) command line
applications developed at the National Center for Biotechnology Information (NCBI).
iv BLAST® Command Line Applications User Manual
Table of Contents
Contributors ........................................................................................................................................................................................................ 1
Introduction.................................................................................................................................................................................................... 3
Installation ........................................................................................................................................................................................................ 5
MacOSX.......................................................................................................................................................................................................... 5
Source tarball................................................................................................................................................................................................. 5
Dependencies .................................................................................................................................................................................................. 7
Run-time .......................................................................................................................................................................................................... 7
Privacy................................................................................................................................................................................................................. 11
BLAST+ features............................................................................................................................................................................................. 17
Tasks ................................................................................................................................................................................................................. 17
Configuring BLAST........................................................................................................................................................................................ 23
Memory usage............................................................................................................................................................................................... 25
Cookbook ........................................................................................................................................................................................................ 29
Extract lowercase masked FASTA from a BLAST database with masking information ................................................................. 47
Display the locations where BLAST will search for BLAST databases ............................................................................................... 48
vi BLAST® Command Line Applications User Manual
Query a BLAST database with an accession, but exclude that accession from the results.......................... 65
Appendices .......................................................................................................................................................................................................... 73
1
Contributors
Christiam Camacho: [email protected]
Thomas Madden: [email protected]
Tao Tao: [email protected]
Richa Agarwala: [email protected]
Aleksandr Morgulis: [email protected]
2 BLAST® Command Line Applications User Manual
3
Introduction
Created: June 23, 2008; Updated: January 7, 2021.
Sequence similarity searching is one of the more important bioinformatics activities and often provides the first
evidence for the function of a newly sequenced gene or piece of sequence. Basic Local Alignment Search Tool
(BLAST) is probably the most popular similarity search tool. The National Center for Biotechnology
Information (NCBI) first introduced BLAST in 1989. The NCBI has continued to maintain and update BLAST
since the first version. In 2009, the NCBI introduced a new version of the stand-alone BLAST applications
(BLAST+). The BLAST+ applications have a number of improvements that allow faster searches as well as more
flexibility in output formats and in the search input. These improvements include: splitting of longer queries so
as to reduce the memory usage and to take advantage of modern CPU architectures; use of a database index to
dramatically speed up the search; the ability to save a “search strategy” that can be used later to start a new
search; and greater flexibility in the formatting of tabular results.
The functionality of the BLAST+ applications is organized by search type. As an example, there is a “blastp”
application that compares proteins queries to protein databases. The “blastx” application translates a nucleotide
query in six frames and searches it against a protein database. This organization is different from that of the
applications first released in 1997 (e.g., blastall) that supported all types of searches with one application, but it
resembles that of the NCBI BLAST web site. An advantage of this design is that each application has only the
options relevant to the searches it performs. Additionally, each application can compare a query to a set of
FASTA sequences in a file, bypassing the need to create a BLAST database for small and infrequently searched
sets. Finally, a “remote” option permits each application to send off a search to the NCBI servers.
This manual has several sections. It provides brief installation instructions, a QuickStart, a section describing
BLAST+ features in more depth, a “Cook Book” section on how to perform a number of tasks, as well as three
appendices. The first appendix discusses tools to help with the transition from the older applications (e.g.,
blastall) to the BLAST+ applications. The second appendix documents exit codes from the BLAST+ applications.
The third appendix is a table of BLAST options, the type of input required, and the default values for each
application. The fourth appendix lists the scoring parameters that the blastn application supports.
An introduction to BLAST is outside the scope of this manual, more information on this subject can be found on
http://blast.ncbi.nlm.nih.gov/Blast.cgi?CMD=Web&PAGE_TYPE=BlastDocs.
Please feel free to contact us with any questions, feedback, or bug reports at [email protected].
4 BLAST® Command Line Applications User Manual
5
Installation
Created: June 23, 2008; Updated: January 7, 2021.
Installation instructions are available for Windows and LINUX/UNIX. This section provides instructions for a
few cases not covered by those entries.
The BLAST+ applications are distributed both as an executable and as source code. For the executable formats
we provide installers as well as tarballs; the source code is only provided as a tarball. These are freely available at
ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/. Please be sure to use the most recent available version; this
will be indicated in the file name (for instance, in the sections below, version 2.2.18 is listed, but this should be
replaced accordingly).
MacOSX
For users without administrator privileges: follow the procedure described in http://www.ncbi.nlm.nih.gov/
books/NBK52640/
For users with administrator privileges and machines MacOSX version 10.5 or higher: Download the ncbi-
blast-2.2.18+.dmg installer and double click on it. Double click the newly mounted ncbi-blast-2.2.18+ volume,
double click on ncbi-blast-2.2.18+.pkg and follow the instructions in the installer. By default the BLAST+
applications are installed in /usr/local/ncbi/blast, overwriting its previous contents (an uninstaller is provided
and it is recommended when upgrading a BLAST+ installation).
RedHat Linux
Download the appropriate *.rpm file for your platform and either install or upgrade the ncbi-blast+ package as
appropriate using the commands:
Install:
rpm -ivh ncbi-blast-2.2.18-1.x86_64.rpm
Upgrade:
rpm -Uvh ncbi-blast-2.2.18-1.x86_64.rpm
Note: one must have root privileges to run these commands. If you do not have root privileges, please use the
procedure described in http://www.ncbi.nlm.nih.gov/books/NBK52640/
Source tarball
Use this approach to build the BLAST+ applications yourself. Download the tarball, expand it, change
directories to the newly created directory, and type the following commands:
cd c++
./configure
cd ReleaseMT/build
make all_r
The compiled executables will be found in c++/ReleaseMT/bin. Please note that this sequence of commands will
build the applications with optimizations, with support for multi-threading and it may require the installation of
dependencies (see following section). If a different configuration is desired, please use the configure.orig script
located in the same directory.
6 BLAST® Command Line Applications User Manual
Dependencies
Created: June 23, 2008; Updated: January 7, 2021.
Run-time
• For get_species_taxids.sh
⚬ E-Direct: https://dataguide.nlm.nih.gov/edirect/install.html
• For update_blastdb.pl
⚬ Perl: https://www.perl.org/
• For Windows only:
⚬ Visual Studio 2015 C++ redistributable runtime package: https://www.microsoft.com/en-us/
download/details.aspx?id=48145
Compile time
• LMDB library (starting with BLAST+ 2.7.1): needed if you are compiling BLAST from source code.
8 BLAST® Command Line Applications User Manual
9
Quick start
Created: June 23, 2008; Updated: January 7, 2021.
A BLAST search against a database requires at least a –query and –db option. The command:
blastn –db nt –query nt.fsa –out results.out
will run a search of nt.fsa (a nucleotide sequence in FASTA format) against the nt database, printing results to
the file results.out. If “-out results.out” had been left off, the results would have been printed to stdout (i.e., the
screen). The blastn application searches a nucleotide query against a nucleotide database.
To send the search to our servers and databases, add the –remote option:
blastn –db nt –query nt.fsa –out results.out -remote
See more about this option in the section below, BLAST+ remote service.
The BLAST+ applications print documentation when invoked with the –h or –help option. The –h option
provides abbreviated help, and the –help flag provides more extensive documentation. For example, use –help to
get a list of output options for the –outfmt option.
Create a custom database from a multi-FASTA file of sequences with this minimal command:
makeblastdb –in mydb.fsa –dbtype nucl –parse_seqids
See the section below, Building a BLAST database with local sequences, for more details.
The BLAST databases are required to run BLAST locally and to support automatic resolution of sequence
identifiers. Documentation about these identifiers can be found at http://www.ncbi.nlm.nih.gov/toolkit/doc/
book/ch_demo/#ch_demo.T5. The databases may be retrieved automatically with the update_blastdb.pl PERL
script, which is included as part of this distribution. This script will download multiple tar files for each BLAST
database volume if necessary, without having to designate each volume. For example:
./update_blastdb.pl --decompress swissprot
Privacy
Created: June 23, 2008; Updated: January 7, 2021.
Privacy Statement
The BLAST+ executables are command-line tools that you run on non-NCBI computers. No information about
your search is sent over the network, unless you explicitly elect to. This offers you greater privacy control than
using web tools or the -remote option on a BLAST+ executable.
For quality monitoring, the BLAST+ executables, starting with the 2.11.0 release, send some information about
usage statistics back to NCBI. This information is limited to the name of the BLAST executable (e.g., blastp),
database metadata, a few BLAST parameters, as well the number and total size of your queries without any data
association that might reveal the context of your research. No sequences from your queries or database are sent
to the NCBI. An example list is below.
These reports help us improve BLAST as well as measure our impact on the community, which in turn justifies
funds to support and further develop BLAST, so please report your usage.
Note that this environment variable is only set in the shell (i.e. window) you are currently using and will not be
set the next time you login. To permanently opt-out, this variable should be set every time a new shell is opened
or with a configuration file, as described above.
You can also set this environment variable, turning off usage reporting, when using BLAST+ docker by adding
the -e option to your docker invocation:
-e BLAST_USAGE_REPORT=false
program=blastp
queries_length=656
run_time=3.076507
task=blastp
version=2.11.0
User Manual
Tom Madden1
Created: June 23, 2008; Updated: September 25, 2020.
The functionality offered by the BLAST+ applications has been organized by program type, as to more closely
resemble Web BLAST.
As an example, to run a search of a nucleotide query (translated “on the fly” by BLAST) against a protein
database one would use the blastx application. The blastx application will also work in “Blast2Sequences” mode
(i.e.: accept FASTA sequences instead of a BLAST database as targets) and can also send BLAST searches over
the network to the public NCBI server if desired.
The BLAST+ package offers three categories of applications: 1.) search tools, 2.) BLAST database tools, and 3.)
sequence filtering tools. The blastn, blastp, blastx, tblastx, tblastn, psiblast, rpsblast, and rpstblastn are considered
search applications, as they execute a BLAST search, whereas makeblastdb, blastdb_aliastool, makeprofiledb, and
blastdbcmd are considered BLAST database applications, as they either create or examine BLAST databases.
There is also a new set of sequence filtering applications described in the section Sequence filtering applications
and an application to build database indices that greatly speed up megablast in some cases (see section titled
Megablast indexed searches).
BLAST+ features
Tom Madden1
Created: June 23, 2008; Updated: September 25, 2020.
Tasks
The blastn and blastp applications have a –task option. This option sets the parameters (e.g., word-size or gap
values) to typical values for a specific type of search. For example, the “megablast” task is optimized for
intraspecies comparison as it uses a large word-size, whereas “blastn” is better suited for interspecies
comparisons with a shorter word-size. These tasks resemble the “Program Selection” section of the BLAST web
pages and do not preclude the user from setting other options to override those specified by the task. See
Appendix "Options for the command-line application" for documentation on parameter values for different
tasks. The following tasks are currently available:
megablast Traditional megablast used to find very similar (e.g., intraspecies or closely related species) sequences
dc-megablast Discontiguous megablast used to find more distant (e.g., interspecies) sequences
Negative GI lists
Search applications support negative GI lists. This feature provides a means to exclude GIs from a BLAST
database search. The expect values in the BLAST results are based upon the sequences actually searched and not
on the underlying database. For an example, see the cookbook.
Upon encountering this type of input, by default the BLAST+ search applications will try to resolve these
sequence identifiers in locally available BLAST databases first, then in the BLAST databases at NCBI, and finally
in Genbank (the latter two data sources require a properly configured internet connection). These data sources
can be configured via the DATA_LOADERS configuration option and the BLAST databases to search can be
configured via the BLASTDB_PROT_DATA_LOADER and BLASTDB_NUCL_DATA_LOADER configuration
options (see the section on Configuring BLAST).
20 BLAST® Command Line Applications User Manual
Concatenation of queries
BLAST works more efficiently if it scans the database once for multiple queries. This feature is known as
concatenation. It speeds up MegaBLAST searches the most as they spend little time on tasks that consume CPU
and most of the time streaming through the database. BLASTN and discontiguous MegaBLAST searches also
run faster with concatenation, though the effect is less pronounced. BLAST+ applies concatenation on all types
of searches (e.g., also BLASTP, etc.), and it can be very beneficial if the input is a large number of queries in
FASTA format. BLAST+ concatenates queries by grouping them together until a specific number of letters (or
“chunk size”) is reached. Unfortunately, a constant chunk size for each database scan causes certain problems.
For some searches the chunk size is too large, too many letters are searched at once, and the process consumes
too much memory. Tests have shown that the number of successful ungapped extensions performed in the
preliminary stage is a good predictor of overall memory use during a search. The BLASTN application (starting
with the 2.2.28 release) takes advantage of this insight to provide an “adaptive chunk size”. The application starts
with a low initial chunk size of 10,000 bases and records how many successful ungapped extensions were
performed during search. It adjusts the chunk size on the next database scan with a target of performing two
million extensions during the search.
Query concatenation also means that BLAST will produce no output until the first set of concatenated queries
have been processed. Some users find this disconcerting, but it is not a problem.
return a Request ID (RID) as part of the results, and that RID can be used to reformat the results with the
blast_formatter or on the NCBI website. In general, the servers keep the results for an RID for 36 hours. The
BLAST+ applications will use the remote service if the –remote flag is added to the command line. The BLAST+
remote service uses a shared resource (the computers at the NCBI), so only one BLAST+ application should run
remote searches at a time. An example in the cookbook section demonstrates a remote search.
22 BLAST® Command Line Applications User Manual
23
Configuring BLAST
Tom Madden1
Created: June 23, 2008; Updated: September 25, 2020.
The BLAST+ search applications can be configured by means of a configuration file or environment variables.
DATA_LOADERS Data loaders to use for automatic sequence identifier resolution. blastdb,genbank
This is a comma separated list of the following keywords: blastdb,
genbank, and none. The none keyword disables this feature and
takes precedence over any other keywords specified.
The following is an example with comments describing the available parameters for configuration:
; Start the section for BLAST configuration
[BLAST]
; Specifies the path where BLAST databases are installed
BLASTDB=/home/guest/blast/db
; Specifies the data sources to use for automatic resolution
; for sequence identifiers
DATA_LOADERS=blastdb
; Specifies the BLAST database to use resolve protein sequences
BLASTDB_PROT_DATA_LOADER=custom_protein_database
; Specifies the BLAST database to use resolve protein sequences
BLASTDB_NUCL_DATA_LOADER=/home/some_user/my_nucleotide_db
; Windowmasker settings
[WINDOW_MASKER]
WINDOW_MASKER_PATH=/home/guest/blast/db/windowmasker
; end of file
NCBI_DONT_USE_LOCAL_CONFIG If defined, no NCBI configuration file on the local directory or the user’s HOME directory
will be used
BATCH_SIZE See “Controlling concatenation of queries” and “Memory usage” sections below.
NCBI_CONFIG__BLAST__X Assuming X is any of the configuration parameters from the previous section, it serves the
same purpose.
Configuring BLAST 25
BLAST_USAGE_REPORT Specifies whether or not usage information should be returned to the NCBI. Set this variable
to false to disable this feature.
Memory usage
The BLAST search programs can exhaust all memory on a machine if the input is too large or if there are too
many hits to the BLAST database. If this is the case, please see your operating system documentation to limit the
memory used by a program (e.g.: ulimit on Unix-like platforms). Setting the BATCH_SIZE environment
variable as described above may help.
26 BLAST® Command Line Applications User Manual
27
26SPS9_Hs lryagrqtealkcvaqasknrsladfekaltdy---------------------------
F57B9_Ce alkyngsdldamkaiaaaaqkrslkdfqvafgsf--------------------------
YDL097c_Sc akytketyqsrgidamkavaeaynnrslldfntalkqy----------------------
YMJ5_Ce ivayqkspriiairsmadafrkrslkdfvkalaeh-------------------------
FUS6_ARATH asglahlelkkyklaarkfldvnpelgnsyneviapqdiatygglcalasfdrselkqkv
COS41.8_Ci kfleaaqrynelsyksaiheteqtkalekalncailapagqqrsrmlatlfkdercqllp
644879 qailtklkcaaglaelaarkykqaakclllasfdhcdfpellspsnvaiygglcalatfd
YPR108w_Sc llslisttaalqsissltislyasdyasyfpyllety-----------------------
eif-3p110_Hs ------------------------------------------------------------
T23D8.4_Ce ------------------------------------------------------------
YD95_Sp vlavlpqnesmssleacinslylcdysgffrtladve-----------------------
KIAA0107_Hs ilevlhslpavrqylfslyecrysvffqslavv---------------------------
F49C12.8_Hs vqeqltggglngtlipvreylesyydchydrffiqlaale--------------------
Int-6_Mm idnnsvssplqslqqrtwlihwslfvffnhpkgrdniidlflyqpqylnaiqtmcphilr
26SPS9_Hs ------------------------------------------------------------
F57B9_Ce ------------------------------------------------------------
YDL097c_Sc ------------------------------------------------------------
YMJ5_Ce ------------------------------------------------------------
FUS6_ARATH idninfrnflelvpdvrelindfyssryascleylasl----------------------
COS41.8_Ci sfgilekmfldriiksdemeefar------------------------------------
644879 rqelqrnvissssfklflelepqvrdiifkfyeskyasclkmldem--------------
YPR108w_Sc ------------------------------------------------------------
eif-3p110_Hs ------------------------------------------------------------
T23D8.4_Ce ------------------------------------------------------------
YD95_Sp ------------------------------------------------------------
KIAA0107_Hs ------------------------------------------------------------
F49C12.8_Hs ------------------------------------------------------------
Int-6_Mm ylttavitnkdvrkrrqvlkdlvkviqqesytykdpitefveclyvnfdfdgaqkklrec
26SPS9_Hs RAELRDDPIISTHLAKLYDNLLEQNLIRVIEPFSRVQIEHISSLIKLSKADVERKLSQMI
F57B9_Ce PQELQMDPVVRKHFHSLSERMLEKDLCRIIEPYSFVQIEHVAQQIGIDRSKVEKKLSQMI
YDL097c_Sc EKELMGDELTRSHFNALYDTLLESNLCKIIEPFECVEISHISKIIGLDTQQVEGKLSQMI
YMJ5_Ce KIELVEDKVVAVHSQNLERNMLEKEISRVIEPYSEIELSYIARVIGMTVPPVERAIARMI
FUS6_ARATH KSNLLLDIHLHDHVDTLYDQIRKKALIQYTLPFVSVDLSRMADAFKTSVSGLEKELEALI
COS41.8_Ci QLMPHQKAITADGSNILHRAVTEHNLLSASKLYNNIRFTELGALLEIPHQMAEKVASQMI
644879 KDNLLLDMYLAPHVRTLYTQIRNRALIQYFSPYVSADMHRMAAAFNTTVAALEDELTQLI
YPR108w_Sc ANVLIPCKYLNRHADFFVREMRRKVYAQLLESYKTLSLKSMASAFGVSVAFLDNDLGKFI
eif-3p110_Hs DLFPEADKVRTMLVRKIQEESLRTYLFTYSSVYDSISMETLSDMFELDLPTVHSIISKMI
T23D8.4_Ce NLFHNAETVKGMVVRRIQEESLRTYLLTYSTVYATVSLKKLADLFELSKKDVHSIISKMI
YD95_Sp VNHLKCDQFLVAHYRYYVREMRRRAYAQLLESYRALSIDSMAASFGVSVDYIDRDLASFI
KIAA0107_Hs EQEMKKDWLFAPHYRYYVREMRIHAYSQLLESYRSLTLGYMAEAFGVGVEFIDQELSRFI
F49C12.8_Hs SERFKFDRYLSPHFNYYSRGMRHRAYEQFLTPYKTVRIDMMAKDFGVSRAFIDRELHRLI
Int-6_Mm ESVLVNDFFLVACLEDFIENARLFIFETFCRIHQCISINMLADKLNMTPEEAERWIVNLI
26SPS9_Hs LDKKFHGILDQGEGVLIIFDEPP
F57B9_Ce LDQKLSGSLDQGEGMLIVFEIAV
YDL097c_Sc LDKIFYGVLDQGNGWLYVYETPN
YMJ5_Ce LDKKLMGSIDQHGDTVVVYPKAD
FUS6_ARATH TDNQIQARIDSHNKILYARHADQ
COS41.8_Ci CESRMKGHIDQIDGIVFFERRET
644879 LEGLISARVDSHSKILYARDVDQ
YPR108w_Sc PNKQLNCVIDRVNGIVETNRPDN
eif-3p110_Hs INEELMASLDQPTQTVVMHRTEP
T23D8.4_Ce IQEELSATLDEPTDCLIMHRVEP
YD95_Sp PDNKLNCVIDRVNGVVFTNRPDE
KIAA0107_Hs AAGRLHCKIDKVNEIVETNRPDS
F49C12.8_Hs ATGQLQCRIDAVNGVIEVNHRDS
Int-6_Mm RNARLDAKIDSKLGHVVMGNNAV
29
Cookbook
Created: June 23, 2008; Updated: January 7, 2021.
30 BLAST® Command Line Applications User Manual
31
The best way to obtain BLAST databases is to download them from NCBI or cloud providers (currently from
Google Cloud Platform and Amazon Web Services). These are the same databases available via the public
BLAST Web Service (https://blast.ncbi.nlm.nih.gov), are updated regularly, and contain taxonomic information
built into them. These can also be a source of biological sequence data (see below).
To download a preformatted NCBI BLAST database, run the update_blastdb.pl program followed by any
relevant options and the name(s) of the BLAST databases to download. For example:
$ update_blastdb.pl --decompress nr [*]
This command will download the compressed nr BLAST database from NCBI to the current working directory
and decompress it. Any subsequent identical invocations of this script with the same parameters in that
directory will only download any data if it has a different time stamp when compared to the data at NCBI.
The update_blastdb.pl script can determine if you are calling it from within a cloud provider and will
automatically download from the appropriate cloud bucket.
If you would like to see what BLAST databases are available to download, please run:
$ update_blastdb.pl --showall [*]
For more information on available NCBI BLAST databases, please see https://go.usa.gov/xPhky . For a demo of
this tool, please see https://bit.ly/2UA7tYb (external link).
For more details about what command line options this tool supports, please run:
$ update_blastdb.pl --help
If you need FASTA from these BLAST databases, you can obtain it as follows:
$ blastdbcmd -entry all -db nr -out nr.fsa
If you need FASTA for selected sequence(s) from these BLAST databases, you can obtain it as follows (the
sequence of interest is identified by the accession u00001 in this example):
$ blastdbcmd -entry u00001 -db nr -out u00001.fsa
[*] If you run into any problems with this invocation, please try the –passive option, which is enabled by default
in BLAST+ 2.8.1 and following. The --decompress option is only needed if the source data comes from NCBI
32 BLAST® Command Line Applications User Manual
33
Here we specify the input is a BLAST database named hs_chr (-in hs_chr -infmt blastdb), enable the sequence id
parsing (-parse_seqids), request the mask data in binary asn.1 format (-outfmt maskinfo_asn1_bin), and name
the output file as hs_chr_dust.asnb (-out hs_chr_dust.asnb).
If the input format is the original FASTA file, hs_chr.fa, we need to change input to -in and -infmt options as
follows:
$ dustmasker -in hs_chr.fa -infmt fasta -parse_seqids \
-outfmt maskinfo_asn1_bin -out hs_chr_dust.asnb
Here we specify the input BLAST database (-in hs_chr -infmt blastdb), request it to generate the counts (-
mk_counts) with sequence id parsing (-parse_seqids), and save the output to a file named hs_chr_mask.counts
(-out hs_chr_mask.counts).
To use the FASTA file hs_chr.fa to generate the counts, we need to change the input file name and format:
34 BLAST® Command Line Applications User Manual
With the counts file we can then proceed to create the file containing the masking information as follows:
$ windowmasker -in hs_chr -infmt blastdb -ustat hs_chr_mask.count \
-outfmt maskinfo_asn1_bin -parse_seqids -out hs_chr_mask.asnb
Here we need to use the same input (-in hs_chr -infmt blastdb) and the output of step 1 (-ustat
hs_chr_mask.counts). We set the mask file format to binary asn.1 (-outfmt maskinfo_asn1_bin), enable the
sequence ids parsing (-parse_seqids), and save the masking data to hs_chr_mask.asnb (-out hs_chr_mask.asnb).
To use the FASTA file hs_chr.fa, we change the input file name and file type:
$ windowmasker -in hs_chr.fa -infmt fasta -ustat hs_chr.counts \
-outfmt maskinfo_asn1_bin -parse_seqids -out hs_chr_mask.asnb
Here we specify the refseq_protein BLAST database (-in refseq_protein -infmt blastdb), enable sequence ids
parsing (-parse_seqids), request the mask data in binary asn.1 format (-outfmt maskinfo_asn1_bin), and name
the out file as refseq_seg.asnb (-out refseq_seg.asnb).
If the input format is the FASTA file, we need to change the command line to specify the input format:
$ segmasker -in refseq_protein.fa -infmt fasta -parse_seqids \
-outfmt maskinfo_asn1_bin -out refseq_seg.asnb
Here the input is hs_chr.mfa (-in hs_chr.mfa), enable parsing of sequence ids, specify the masking algorithm
name (-masking_algorithm repeat) and its parameter (-masking_options “repeatmasker, default”), and ask for
asn.1 output (-outfmt maskinfo_asn1_bin) to be saved in specified file (-out hs_chr_mfa.asnb).
that (virtual) and doesn’t depend on the hardware in your system. In general, we recommend that BLAST
users simply set the virtual memory to unlimited.
Here, we use the existing BLAST database as input file (-in hs_chr), specify its type (-dbtype nucl), enable
parsing of sequence ids (-parse_seqids), provide the masking data (-mask_data hs_chr_mask.asnb), and name
the output database with the same base name (-out hs_chr) overwriting the existing one.
To use the original FASTA sequence file (hs_chr.fa) as the input, we need to use “-in hs_chr.fa” to instruct
makeblastdb to use that FASTA file instead.
We can check the “re-created” database to find out if the masking information was added properly, using
blastdbcmd with the following command line:
$ blastdbcmd -db hs_chr -info
Volumes:
/export/home/tao/blast_test/hs_chr
Extra lines under the “Available filtering algorithms …” describe the masking algorithms available. The
“Algorithm ID” field, 30 in our case, is what we need to use if we want to invoke database soft masking during an
actual search through the “-db_soft_mask” parameter.
We can apply additional masking data to an existing BLAST database with one type of masking information
already added. For example, we can apply the dust masking generated above to the database generated earlier by
using this command line:
$ makeblastdb -in hs_chr –input_type blastdb -dbtype nucl -parse_seqids \
-mask_data hs_chr_dust.asnb -out hs_chr -title "Human Chromosome, Ref B37.1"
Here, we use the existing database as input file (-in hs_chr), specify its input and molecule type (-input_type
blastdb -dbtype nucl), enable parsing of sequence ids (-parse_seqids), provide the dust masking data (-
mask_data hs_chr_dust.asnb), naming the database with the same based name (-out hs_chr) overwriting the
existing one.
Checking the “re-generated” database with blastdbcmd:
36 BLAST® Command Line Applications User Manual
Volumes:
/net/gizmo4/export/home/tao/blast_test/hs_chr
A more straightforward approach to apply multiple sets of masking information in a single makeblastdb run by
providing multiple set of masking data files in a comma delimited list:
$ makeblastdb -in hs_chr –input_type blastdb -dbtype nucl -parse_seqids \
-mask_data hs_chr_dust.asnb, hs_chr_mask.asnb -out hs_chr
This produces the following summary, which includes the masking information:
Database: RefSeq Protein Database
7,044,477 sequences; 2,469,203,411 total residues
Volumes:
/export/home/tao/blast_test/refseq_protein2.00
/export/home/tao/blast_test/refseq_protein2.01
/export/home/tao/blast_test/refseq_protein2.02
Here we use the lowercase masked FASTA sequence file as input (-in hs_chr.mfa), its file type (-input_type fasta),
specify the database as nucleotide (-dbtype nucl), enable parsing of sequence ids (-parse_seqids), provide the
masking data (-mask_data hs_chr_mfa.asnb), and name the resulting database as hs_chr_mfa (-out
hs_chr_mfa).
Checking the database thus generated using blastdbcmd, we have:
Database: Human chromosomes (mfa)
24 sequences; 3,095,677,412 total bases
Volumes:
/export/home/tao/hs_chr_mfa
The algorithm name and algorithm options are the values we provided in “Extract masking information from
FASTA sequences with lowercase masking”.
We use this command line to create the BLAST database from the input nucleotide sequences:
$ makeblastdb -in hs_chr.fa -dbtype nucl -parse_seqids \
-out hs_chr -title "Human chromosomes, Ref B38"
For input nucleotide sequences with lowercase masking, we use the FASTA file hs_chr.mfa, containing the
complete human chromosomes from BUILD37.1, generated by inflating and combining the hs_ref_*.mfa.gz files
located in the same ftp directory.
For input protein sequences, we use the preformatted refseq_protein database from the NCBI blast/db/ ftp
directory:
ftp.ncbi.nlm.nih.gov/blast/db/refseq_protein.00.tar.gz
ftp.ncbi.nlm.nih.gov/blast/db/refseq_protein.01.tar.gz
ftp.ncbi.nlm.nih.gov/blast/db/refseq_protein.02.tar.gz
38 BLAST® Command Line Applications User Manual
39
Database masking has two modes. The first is known as "soft-masking", and BLAST uses the database mask only
during the (initial) word-finding phase of BLAST. The second is known as "hard-masking", and BLAST uses the
database mask during all phases of the search. Here, we look at both types of masking.
To enable database masking during a BLAST search, we use the –info parameter of blastdbcmd to discover the
masking Algorithm ID. For the database generated in the previous cookbook entry, we can use the following
command line to activate the windowmasker soft masking:
$ blastn -query HTT_gene -task megablast -db hs_chr -db_soft_mask 30 \
-outfmt 7 -out HTT_megablast_softmask.out -num_threads 4
Here, we search a nucleotide query, HTT_gene* (-query HTT_gene), with the megablast algorithm (-task
megablast) against the database hs_chr (-db hs_chr). We use soft masking (-db_soft_mask 30), set the result
format to tabular output (-outfmt 7), and save the result to a file named HTT_megablast_softmask.tab (-out
HTT_megablast_softmask.tab). We also activated the multi-threaded feature of blastn to speed up the search by
using 4 CPUs$ (-num_threads 4).
For the database generated in the previous cookbook entry, we can use the following command line to activate
the windowmasker hard masking:
$ blastn -query HTT_gene -task megablast -db hs_chr -db_hard_mask 30 \
-outfmt 7 -out HTT_megablast_hardmask.out -num_threads 4
The options are similar to the ones for soft masking, except that we use –db_hard_mask rather than –
db_soft_mask. Additionally, we changed the name of the output file.
Hard masking is much more aggressive than soft masking. In interspersed or simple repeats, soft masking
normally provides the best results. Hard masking may be warranted to remove vector or other contamination
from the BLAST results.
*This is a genomic fragment containing the HTT gene from human, including 5 kb up- and down-stream of the
transcribed region. It is represented by NG_009378.
$ The number to use under in your run will depend on the number of CPUs your system has.
In a test run under a 64-bits Linux machine, the search with soft masking took about 1.5 seconds real time, and
the search with hard masking took about 2.5 seconds real time. The search without database masking took about
31 minutes.
40 BLAST® Command Line Applications User Manual
41
The –outfmt option permits formatting arbitrary fields from the BLAST tabular and comma-separated-value
(CSV) formats. Use the –help option on the command-line application (e.g., blastn) to see the supported fields.
The max_target_seqs option should be used with any tabular output to control the number of matches reported.
replaced by G), or 3.) a dash (“-“) and a letter showing a gap. The box below shows a blastn run first with BTOP
output and then the same run with the BLAST report showing the alignments.
$ blastn -query test_q.fa -subject test_s.fa -dust no -outfmt "6
qseqid sseqid btop" -parse_deflines
query1 q_multi 7AG39
query1 q_multi 7A-39
query1 q_multi 6-G-A41
$ blastn -query test_q.fa -subject test_s.fa -dust no -parse_deflines
BLASTN 2.2.24+
Query= query1
Length=47
Subject=
Length=142
Query 1 ACGTCCGAGACGCGAGCAGCGAGCAGCAGAGCGACGAGCAGCGACGA 47
||||||| |||||||||||||||||||||||||||||||||||||||
Sbjct 47 ACGTCCGGGACGCGAGCAGCGAGCAGCAGAGCGACGAGCAGCGACGA 93
Query 1 ACGTCCGAGACGCGAGCAGCGAGCAGCAGAGCGACGAGCAGCGACGA 47
||||||| |||||||||||||||||||||||||||||||||||||||
Sbjct 1 ACGTCCG-GACGCGAGCAGCGAGCAGCAGAGCGACGAGCAGCGACGA 46
Query 1 ACGTCC--GAGACGCGAGCAGCGAGCAGCAGAGCGACGAGCAGCGACGA 47
|||||| |||||||||||||||||||||||||||||||||||||||||
Sbjct 94 ACGTCCGAGAGACGCGAGCAGCGAGCAGCAGAGCGACGAGCAGCGACGA 142
43
Often, one needs to search multiple databases together or wishes to search a specific subset of sequences within
an existing database. For these type of searches a convenient way to conduct them is by creating a virtual BLAST
database. The blastdb_aliastool can perform three types of tasks to assist in that process. First, it can build an
alias file to transparently combine searches of different databases. Second, it can build an alias file that limits a
search based on a list of GIs (numerical IDs) or accessions. Finally, it can convert the list of GI’s or accessions to a
more efficient binary format.
Note: When combining BLAST databases, all the databases must be of the same molecule type. The following
examples assume that the two databases as well as the GI file are in the current working directory. The binary
format for accessions is only supported in the newer version 5 of the BLAST databases (BLAST+ 2.10.0 or newer
suggested). Version 5 of the BLAST databases supports limiting a search natively by taxonomy, and only the
relevant TAXIDs are needed.
Note: one can also specify multiple databases using the -db parameter of blastdb_aliastool.
It may be helpful to view the same BLAST results in different formats. A user may first parse the tabular format
looking for matches meeting a certain criteria, then go back and examine the relevant alignments in the full
BLAST report. He may also first look at pair-wise alignments, then decide to use a query-anchored view.
Viewing a BLAST report in different formats has been possible on the NCBI BLAST web site since 2000, but has
not been possible with stand-alone BLAST runs. The blast_formatter allows this, if the original search produced
blast archive format using the –outfmt 11 switch. The query sequence, the BLAST options, the masking
information, the name of the database, and the alignment are written out as ASN.1 (a structured format similar
to XML). The –max_target_seqs option should be used to control the number of matches recorded in the
alignment. The blast_formatter reads this information and formats a report. The BLAST database used for the
original search must be available, or the sequences need to be fetched from the NCBI, assuming the database
contains sequences in the public dataset. The box below illustrates the procedure. A blastn run first produces the
BLAST archive format, and the blast_fomatter then reads the file and produces tabular output.
Blast_formatter will format stand-alone searches performed with an earlier version of a database if both the
search and formatting databases are prepared so that fetching by sequence ID is possible. To enable fetching by
sequence ID use the –parse_seqids flag when running makeblastdb, or (if available) download preformatted
BLAST databases from ftp://ftp.ncbi.nlm.nih.gov/blast/db/ using update_blastdb.pl (provided as part of the
BLAST+ package). Currently the blast archive format and blast_formatter do not work with database free
searches (i.e., -subject rather than –db was used for the original search).
$ echo 1786181 | blastn -db ecoli -outfmt 11 -out out.1786181.asn
$ blast_formatter -archive out.1786181.asn -outfmt "7 qacc sacc evalue
qstart qend sstart send"
# BLASTN 2.2.24+
# Query: gi|1786181|gb|AE000111.1|AE000111 Escherichia coli K-12 MG1655
section 1 of 400
# Database: ecoli
# Fields: query acc., subject acc., evalue, q. start, q. end,
s. start, s. end
# 85 hits found
AE000111 AE000111 0.0 1 10596 1 10596
AE000111 AE000174 8e-30 5565 5671 6928 6821
AE000111 AE000394 1e-27 5587 5671 135 219
AE000111 AE000425 6e-26 5587 5671 8552 8468
AE000111 AE000171 3e-24 5587 5671 2214 2130
AE000111 AE000171 1e-23 5587 5670 10559 10642
AE000111 AE000376 1e-22 5587 5675 129 42
AE000111 AE000268 1e-22 5587 5671 6174 6090
AE000111 AE000112 1e-22 10539 10596 1 58
AE000111 AE000447 5e-22 5587 5670 681 598
AE000111 AE000344 6e-21 5587 5671 4112 4196
AE000111 AE000490 2e-20 5584 5671 4921 4835
AE000111 AE000280 2e-20 5587 5670 12930 12847
46 BLAST® Command Line Applications User Manual
47
Volumes:
mask-data-db
$ blastdbcmd -db mask-data-db -mask_sequence_with 20 -entry 71022837
>gi|71022837|ref|XP_761648.1| hypothetical protein UM05501.1 [Ustilago maydis 521]
MPPSARHSAHPSHHPHAGGRDLHHAAGGPPPQGGPGMPPGPGNGPMHHPHSSYAQSMPPPPGLPPHAMNGINGPPPSTHG
GPPPRMVMADGPGGAGGPPPPPPPHIPRSSSAQSRIMEAaggpagpppagppastspavQklslANEaawvsIGsaaetm
EdydralsayeaalrhnpysvpalsaiagvhrtldnfekavdyfqrvlnivpengdTWGSMGHCYLMMDDLQRAYTAYQQ
ALYHLPNPKEPKLWYGIGILYDRYGSLEHAEEAFASVVRMDPNYEKANEIYFRLGIIYKQQNKFPASLECFRYILDNPPR
PLTEIDIWFQIGHVYEQQKEFNAAKEAYERVLAENPNHAKVLQQLGWLYHLSNAGFNNQERAIQFLTKSLESDPNDAQSW
YLLGRAYMAGQNYNKAYEAYQQAVYRDGKNPTFWCSIGVLYYQINQYRDALDAYSRAIRLNPYISEVWFDLGSLYEACNN
QISDAIHAYERAADLDPDNPQIQQRLQLLRNAEAKGGELPEAPVPQDVHPTAYANNNGMAPGPPTQIGGGPGPSYPPPLV
GPQLAGNGGGRGDLSDRDLPGPGHLGSSHSPPPFRGPPGTDDRGARGPPHGALAPMVGGPGGPEPLGRGGFSHSRGPSPG
PPRMDPYGRRLGSPPRRSPPPPLRSDVHDGHGAPPHVHGQGHGQGHGQGHGQGHGQGHGQSHGHSHGGEFRGPPPLAAAG
PGGPPPPLDHYGRPMGGPMSEREREMEWEREREREREREQAARGYPASGRITPKNEPGYARSQHGGSNAPSPAFGRPPVY
GRDEGRDYYNNSHPGSGPGGPRGGYERGPGAPHAPAPGMRHDERGPPPAPFEHERGPPPPHQAGDLRYDSYSDGRDGPFR
GPPPGLGRPTPDWERTRAGEYGPPSLHDGAEGRNAGGSASKSRRGPKAKDELEAAPAPPSPVPSSAGKKGKTTSSRAGSP
WSAKGGVAAPGKNGKASTPFGTGVGAPVAAAGVGGGVGSKKGAAISLRPQEDQPDSRPGSPQSRRDASPASSDGSNEPLA
ARAPSSRMVDEDYDEGAADALMGLAGAASASSASVATAAPAPVSPVATSDRASSAEKRAESSLGKRPYAEEERAVDEPED
SYKRAKSGSAAEIEADATSGGRLNGVSVSAKPEATAAEGTEQPKETRTETPPLAVAQATSPEAINGKAESESAVQPMDVD
GREPSKAPSESATAMKDSPSTANPVVAAKASEPSPTAAPPATSMATSEAQPAKADSCEKNNNDEDEREEEEGQIHEDPID
APAKRADEDGAK
$
The first column of the default output is the file name of the BLAST database (usually provided as the –db
argument to other BLAST+ applications), the second column represents the molecule type of the BLAST
database. This output is configurable via the list_outfmt command line option.
49
The blastn executable can filter a query sequence using the windowmasker data files. This option can be used to
mask interspersed repeats that may lead to spurious matches. The windowmasker data files should be created as
discussed in step 1 of “Create masking information using windowmasker” or downloaded from the NCBI FTP
site. Follow the instructions in Configuring BLAST to make sure BLAST will be able to find the windowmasker
files in the examples below.
1. Run BLAST search using Windowmasker for sequence filtering based upon taxid
(9606 is the taxid for human).
$ blastn -query input -db database -window_masker_taxid 9606 -out results.txt
2. Run BLAST search using Windowmasker for sequence filtering based upon the windowmasker
file name.
$ blastn –query input –db database –window_masker_db 9606/wmasker.obinary
50 BLAST® Command Line Applications User Manual
51
If you would like to search the BLAST databases NCBI offers, please see Get NCBI BLAST databases
The makeblastdb application produces BLAST databases from FASTA files. It is possible to use completely
unstructured (or even blank) FASTA definition lines, but this is not the recommended procedure. Assigning a
unique identifier to every sequence in the database allows you to retrieve the sequence by identifier and allows
you to associate every sequence with a taxonomic node (through the taxid of the sequence). The unique
identifier can be a simple string (as in the example below) or could be actual accession of the sequence if the
sequence comes from a public database (e.g., GenBank). Being able to associate a database sequence with a
taxonomic node is especially powerful for the version 5 databases that BLAST can use to limit the search by
taxonomy. The identifier should begin right after the “>” sign on the definition line and contain no spaces and
the -parse_seqids flag should be used. In general, you should not use a “|” (bar) in your identifier. The “|” (bar) is
a reserved character for the NCBI FASTA ID parser and makeblastdb will return an error unless the bar is used
in a specific manner described at https://ncbi.github.io/cxx-toolkit/pages/ch_demo#ch_demo.T5
An example FASTA file is:
$ cat test.fsa
>seq1
MSFSTKPLDMATWPDFAALVERHNGVWGGCWCMAFHAKGSGAVGNREAKEARVREGSTHAALVFDGSACVGWCQFGPTGE
LPRIKHLRAYEDGQAVLPDWRITCFFSDKAFRGKGVAAAALAGALAEIGRLGGGTVESYPEDAQGRTVAGAFLHNGTLAM
>seq2
MKAIDLKAEEKKRLIEGIQDFFYEERNEEIGIIAAEKALDFFLSGVGKLIYNKALDESKIWFSRRLEDISLDYELLYK
>seq3
MTLAAAAQSATWTFIDGDWYEGNVAILGPRSHAMWLGTSVFDGARWFEGVAPDLELHAARVNASAIALGLAPNMTPEQIV
GLTWDGLKKFDGKTAVYIRPMYWAEHGGYMGVPADPASTRFCLCLYESPMISPTGFSVTVSPFRRPTIETMPTNAKAGCL
YPNNGRAILEAKARGFDNALVLDMLGNVAETGSSNIFLVKDGHVLTPAPNGTFLSGITRSRTMTLLGDYGFRTTEKTLSV
RDFLEADEIFSTGNHSKVVPITRIEGRDLQPGPVAKKARELYWDWAHSASVG
>seq4
MRSFFHHVAAADPASFGVAQRVLTIPIKRAHIEVTHHLTKAEVDALIAAPNPRTSRGRRDRTFLLFLARTGARVSEATGV
NANDLQLERSHPQVLLRGKGRRDRVIPIPQDLARALTALLAEHGIANHEPRPIFIGARQERLTRFGATHIVRRAAAQAVT
IKPALAHKPISPHIFRHSLAMKLLQSGVDLLTIQAWLGHAQVATTHRYAAADVEMMRKGLEKAGVSGDLGLRFRPNDAVL
QLLTSI
>seq5
MTISRVCGSRTEAMLTNGQEIAMTSILKSTGAVALLLLYTLTANATSLMISPSSIERVAPDRAAVFHLRNQMDRPISIKV
RVFRWSQKGGVEKLEPTGDVVASPISAQLSPNGNRAVRVVRVSKEPLRSEEGYRVVIDEADPTRNTPEAESLSARHVLPV
LFRPPDVLGPEIELSLTRSDGWLMLVVENKGASRLRRSDVTLAQGSAGIARREGFVGYVLPGLTRHWRVGREDSYSGGIV
TVSANSSGGAIGEQLVVSGR
>seq6
TTLLLQVPIGWGVLHQGGALVVLGFAIAHWRGFVGTYTRDTAIEMRD
An additional (optional) file mapping the identifiers to taxids (a number identifying a taxonomic node) may be
used to associate each sequence with a taxonomic node.
$ cat test_map.txt
seq1 68287
seq2 2382161
seq3 68287
seq4 382
seq5 382
seq6 382
The taxid for a taxonomic node can be looked up with the get_species_taxids.sh script distributed with the
BLAST+. Additionally, the NCBI provides other resources. The files in https://ftp.ncbi.nlm.nih.gov/pub/
taxonomy/accession2taxid/ provide a mapping from accession to taxid (useful if the sequences are from a public
52 BLAST® Command Line Applications User Manual
If you do add the taxids to your database, make sure you have the BLAST taxonomy data files (taxdb.bt[di])
which are available from https://ftp.ncbi.nlm.nih.gov/blast/db/ but also packaged with most BLAST databases
distributed by the NCBI.
If all of the sequences in your database have the same taxid, you can simply use the -taxid flag on makeblastdb to
associate all sequences with that taxid rather than needing to prepare a file.
For releases prior to BLAST+ 2.9.0, ad hoc identifiers (as shown in our example above) should be prefixed with
“lcl|” (e.g., lcl|seq1 in place of seq1) for the taxid mapping file.
The NCBI makes databases that are searchable on the NCBI web site (such as nr, refseq_rna, and swissprot)
available on its FTP site. It is better to download the preformatted databases rather than starting with FASTA.
The databases on the FTP site contain taxonomic information for each sequence, include the identifier indices
for lookups, and can be up to four times smaller than the FASTA. The original FASTA can be generated from the
BLAST database using blastdbcmd.
Starting with the 2.10.0 release, makeblastdb produces version 5 databases by default, which uses LMDB. LMDB
requires virtual memory (at least 600 GB, but 800 GB is recommended). Virtual memory is just that (virtual)
and doesn’t depend on the hardware in your system. In general, we recommend that BLAST users simply set the
virtual memory to unlimited.
53
In order to limit a BLAST search by taxonomy, one needs to provide the NCBI taxonomy ID(s) (taxid) for given
organism(s). A taxid is simply a number that specifies a node in the taxonomic tree. For example, 9606 is the
taxid for human, 9989 is the taxid for rodentia, and 2 is the taxid for all bacteria. Taxids are preferable to
organism names as the latter can be ambiguous. For instance, bacteria is both a genus of insects as well as a
superkingdom. BLAST only accepts taxids that are at or below the species level.
The BLAST+ command line tool suite provides the get_species_taxids.sh script to translate higher level taxids
(e.g.: Enterobacterales) into a list of taxids that are at the appropriate level. This script can also be used to look up
(and disambiguate) taxids based upon a taxonomic name. If unsure whether your taxid is at the species level or
lower, it is safe to run get_species_taxids.sh and feed the output to BLAST.
Additionally, one may use the -negative_taxids and -negative_taxidlist options to exclude sequences by taxid.
Note: this script depends on EDirect and it only works on Linux and Mac. For EDirect installation instructions,
please see https://www.ncbi.nlm.nih.gov/books/NBK179288/ .
BLAST can also limit a database search by a list of identifiers (e.g.: accessions), which should be specified one per
line in a file. These identifiers, referencing the sequences to include or exclude in the BLAST search, should not
contain any whitespace and should be retrievable from the BLAST database.
Starting with BLASTDB version 5, an accession list must be pre-processed before it can be used in a search. This
process checks that the accessions appear to be real and produces a file optimized for use with BLAST. It is also
possible to confirm that all the accessions are actually in the target database. The examples below demonstrate
this functionality:
# 9606.pacc is a text file with protein accessions. This command produces a file called
9606.pacc.bsl
$ blastdb_aliastool -seqid_file_in 9606.pacc
Additionally, one may use the -negative_seqidlist option to exclude sequences by accession from the BLAST
search.
When the search is limited by a list of IDs the statistics of the BLAST database are re-calculated to reflect the
actual number of sequences and residues/bases included in the search.
56 BLAST® Command Line Applications User Manual
57
BLAST has been able to search multiple databases since 1997. The databases can be listed after the “-db”
argument or in an alias file (see cookbook entries on blastdb_aliastool), separated by spaces. Many operating
systems now allow spaces in filenames and directory paths, so some care is required. Basically, one should always
have two sets of quotes for any path containing a space. Blastdbcmd is used as an example below, but the same
rules apply to makeblastdb as well as the search programs like blastn or blastp.
To access a BLAST database containing spaces under Microsoft Windows it is necessary to use two sets of
double-quotes, escaping the innermost quotes with a backslash. For example, Users\joeuser\My Documents
\Downloads would be accessed by:
blastdbcmd -db "\"Users\joeuser\My Documents\Downloads\mydb\"" -info
The first backslash escapes the beginning inner quote, and the backslash following “mydb” escapes the ending
inner quote.
A second database can be added to this command by including it within the outer pair of quotes:
blastdbcmd -db "\"Users\joeuser\My Documents\Downloads\mydb\" myotherdb" -info
If the second database had contained a space, it would have been necessary to surround it by quotes escaped by a
backslash.
Under UNIX systems (including LINUX and Mac OS X) it is preferable to use a single quote (‘) in place of the
escaped double quote:
blastdbcmd -db ‘ "path with spaces/mydb" ’ -info
Multiple databases can also be listed within the single quotes, similar to the procedure described for Microsoft
Windows.
58 BLAST® Command Line Applications User Manual
59
The -in_msa psiblast option, unlike blastpgp, does not support the specification of a master sequence via the -
query option, so if one wants to specify a sequence (other than the first one) in the multiple sequence alignment
file to be the master sequence, this has to be specified via the -msa_master_idx option. For instance, in the
example below, the third sequence in the multiple sequence alignment would be used as the master sequence:
psiblast -in_msa align1 -db pataa -msa_master_idx 3
60 BLAST® Command Line Applications User Manual
61
Often a consensus sequence is added to a multiple sequence alignment to be used as the master sequence in a
PSI-BLAST search. The consensus sequence provides a good option to display the query-subject alignment in
the output and to define which MSA columns are to be converted to PSSM. At the same time adding the
consensus sequence changes the statistical properties of the original alignment. To avoid this, the -
ignore_msa_master option can be used:
psiblast -in_msa align1 -db pataa -ignore_msa_master
In this case the master sequence is displayed in the output but ignored when the PSSM scores are calculated.
62 BLAST® Command Line Applications User Manual
63
DELTA-BLAST searches a protein sequence database using a PSSM constructed from conserved domains
matching a query. It first searches the NCBI CDD database to construct the PSSM.
The BLAST databases may contain filtering (or masking) information for the database sequences. Makembindex
can access this information and exclude the masked regions of the database from the index. This is demonstrated
below. The first command shows how to discover the masking “Algorithm ID” from the BLAST database using
blastdbcmd. In this case, the ID is 30. The second command demonstrates how to build an index that excludes
the masked regions. Once the index has been built, it can be used as shown above. In the example below, the
ref_contig BLAST database had been placed in the directory before makembindex was run.
$ blastdbcmd -db ref_contig -info
Database: ref_contig
364 sequences; 2,938,626,560 total bases
Starting with BLASTDB version 5, blastdbcmd has two additional parameters (-taxids and -taxidlists) to
efficiently retrieve sequences by taxid.
# Retrieves all human entries;
# %a prints the accession, %T prints the taxid, %S prints the scientific name
$ blastdbcmd -db nr -taxids 9606 -outfmt “%a %T %S” -target_only
Note: -target_only is used to ensure that only accessions for the human entries are present. Otherwise, it will
present all accessions on any sequence with at least one human sequence. This is important since nr is a non-
redundant database.
68 BLAST® Command Line Applications User Manual
69
Threading By Query
Tom Madden
Created: June 23, 2008; Updated: June 28, 2021.
Starting in the 2.12.0 release, BLAST supports a different threading model that can be more efficient in certain
situations. This section describes how and when to use that option.
Traditionally, BLAST multi-threads by having each thread work on a subset of the database. Some parts of this
process are single threaded (such as setup and formatting), but for large databases such as nt or nr, this is not
significant. For smaller databases, performance can be poor. We have implemented a multi-threading option
that can be advantageous for batch processing. It works well if you have large numbers of queries with a small
database or limit your search by taxid or by gilist. This option takes many query sequences and assigns them to a
thread, which performs the entire search and formatting of results within that thread. All threads work
independently, eliminating bottlenecks. The order of the query sequences is preserved in the results. We call this
“threading by query”.
You may enable threading by query with the -mt_mode option by providing a value of 1, as shown below. The
default value for the -mt_mode option is 0. You still specify the number of threads with the “-num_threads”
option.
$ blastp –db swissprot -query BIGFASTA.fsa –out test.out -num_threads 32 -mt_mode 1
As noted above, the threading by query option works well with relatively small databases if you have a lot of
queries to process. For BLASTP, your input FASTA should contain at least 10,000 residues per thread, or 320,000
residues for 32 threads. For BLASTX, the FASTA should contain 30,000 bases per thread. For both BLASTP and
BLASTX, we find threading by query works best if the database has fewer than 2 billion residues (e.g, swissprot).
For BLASTN, your FASTA file should contain at least 2.5 million bases per thread and the database should
contain fewer than 14 billion residues. Threading by query also works well if you limit the search, such as by -
taxid or -gilist, regardless of the size of the database.
Here, we show some examples where this strategy works well. Below, the orange lines shows results for threading
by query (mt_mode=1), where each thread works independently on a batch of sequences. The blue line shows
the default method appropriate for large databases or few queries.
70 BLAST® Command Line Applications User Manual
MegaBLAST search of 1,966 sequences (899,809,898 bp) from the Sander lucioperca betanodavirus, whole
genome shotgun sequencing project (https://www.ncbi.nlm.nih.gov/nuccore/CABPSU000000000.1) against the
refseq viral representative genomes database. For 32 threads, the search can be completed more than four times
faster (84 vs. 368 seconds) when threading by query.
Threading By Query 71
BLASTP search of 20,410 proteins from the human gut metagenome WGS project (https://
www.ncbi.nlm.nih.gov/Traces/wgs/AJWY01) against swissprot. For 32 threads, the search is 2.8 times faster (3.4
minutes vs 9.5 minutes) when threading by query. The task blastp-fast was used.
72 BLAST® Command Line Applications User Manual
BLASTP search of 9200 proteins from the refseq_select protein database against refseq_protein limited to
human entries with -taxid flag. For 32 threads, the search is 5.7 times faster (14 minutes vs 80 minutes) when
threading by query. The task blastp-fast was used.
73
Appendices
Tom Madden
Created: June 23, 2008; Updated: June 24, 2021.
The easiest way to get started using the BLAST+ command line applications is by means of the legacy_blast.pl
PERL script which is bundled along with the BLAST+ applications. To utilize this script, simply prefix it to the
invocation of the C toolkit BLAST command line application and append the --path option pointing to the
installation directory of the BLAST+ applications. For example, instead of using
blastall -i query -d nr -o blast.out
use
legacy_blast.pl blastall -i query -d nr -o blast.out
--path /opt/blast/bin
The purpose of the legacy_blast.pl PERL script is to help users make the transition from the C Toolkit BLAST
command line applications to the BLAST+ applications. This script produces its own documentation by
invoking it without any arguments.
The legacy_blast.pl script supports two modes of operation, one in which the C Toolkit BLAST command line
invocation is converted and executed on behalf of the user and another which solely displays the BLAST+
application equivalent to what was provided, without executing the command.
The first mode of operation is achieved by specifying the C Toolkit BLAST command line application invocation
and optionally providing the --path argument after the command line to convert if the installation path for the
BLAST+ applications differs from the default (available by invoking the script without arguments). See example
in the first section of the Quick start.
The second mode of operation is achieved by specifying the C Toolkit BLAST command line application
invocation and appending the --print_only command line option as follows:
$ ./legacy_blast.pl megablast -i query.fsa -d nt -o mb.out --print_only
/opt/ncbi/blast/bin/blastn -query query.fsa -db "nt" -out mb.out
$
Exit codes
All BLAST+ applications have consistent exit codes to signify the exit status of the application. The possible exit
codes along with their meaning are detailed in the table below:
74 BLAST® Command Line Applications User Manual
0 Success
4 Out of memory
In the case of BLAST+ database applications, the possible exit codes are 0 (indicating success) and 1 (indicating
failure).
Table C1: Options common to all BLAST+ search applications. An option of type “flag” takes no argument, but if present is true. Some
options are valid only for a local search (“remote” option not used), others are valid only for a remote search (“remote” option used).
option type default value description and notes
num_descriptions integer 500 Show one-line descriptions for this number of database sequences.
num_alignments integer 250 Show alignments for this number of database sequences.
max_target_seqs integer 500 Number of aligned sequences to keep. Use with report formats that do not have
separate definition line and alignment sections such as tabular (all outfmt > 4). Not
compatible with num_descriptions or num_alignments. Ties are broken by order of
sequences in the database.
max_hsps integer none Maximum number of HSPs (alignments) to keep for any single query-subject pair.
The HSPs shown will be the best as judged by expect value. This number should be an
integer that is one or greater. If this option is not set, BLAST shows all HSPs meeting
the expect value criteria. Setting it to one will show only the best HSP for every
query-subject pair
gilist string none Restrict search of database to GI’s listed in this file. Local searches only.
negative_gilist string none Restrict search of database to everything except the GI’s listed in this file. Local
searches only.
entrez_query string none Restrict search with the given Entrez query. Remote searches only.
culling_limit integer none Delete a hit that is enveloped by at least this many higher-scoring hits.
best_hit_overhang real none Best Hit algorithm overhang value (recommended value: 0.1)
best_hit_score_edge real none Best Hit algorithm score edge value (recommended value: 0.1)
parse_deflines flag N/A Parse query and subject bar delimited sequence identifiers (e.g., gi|129295).
0 = pairwise,
2 = query-anchored no identities,
6 = tabular,
8 = Text ASN.1,
9 = Binary ASN.1
10 = Comma-separated values
11 = BLAST archive format (ASN.1)
12 = Seqalign (JSON),
13 = Multiple-file BLAST JSON,
14 = Multiple-file BLAST XML2,
15 = Single-file BLAST JSON,
16 = Single-file BLAST XML2,
17 = Sequence Alignment/Map (SAM),
18 = Organism Report
staxids means unique Subject Taxonomy ID(s), separated by a ';'(in numerical order)
sblastnames means unique Subject Blast Name(s), separated by a ';' (in alphabetical
order)
Value of 0 indicates that BLAST should multi-thread by having each thread work on a
part of the database. This is appropriate for a small number of queries and a larger
database (e.g., larger than Swissprot). Value 1 indicates that each thread will take a
batch of queries and process them independently. This works well for large query sets
(10k residues per thread for BLASTP and 2 million bases per thread for BLASTN)
and smaller databases (e.g., Swissprot).
Table C2: blastn application options. The blastn application searches a nucleotide query against nucleotide subject sequences or a
nucleotide database. An option of type “flag” takes no arguments, but if present the argument is true. Four different tasks are
supported: 1.) “megablast”, for very similar sequences (e.g, sequencing errors), 2.) “dc-megablast”, typically used for inter-species
comparisons, 3.) “blastn”, the traditional program used for inter-species comparisons, 4.) “blastn-short”, optimized for sequences less
than 30 nucleotides.
option task(s) type default value description and notes
gapopen megablast integer 0 Cost to open a gap. See appendix “BLASTN reward/penalty
values”.
gapextend megablast integer none Cost to extend a gap. This default is a function of reward/
penalty value. See appendix “BLASTN reward/penalty
values”.
Appendices 79
gapopen blastn, blastn-short, integer 5 Cost to open a gap. See appendix “BLASTN reward/penalty
dc-megablast values”.
gapextend blastn, blastn-short, integer 2 Cost to extend a gap. See appendix “BLASTN reward/penalty
dc-megablast values”.
strand all string both Query strand(s) to search against database/subject. Choice of
both, minus, or plus.
filtering_db all string none Mask query using the sequences in this database.
window_masker_taxid all integer none Enable WindowMasker filtering using a Taxonomic ID.
window_masker_db all string none Enable WindowMasker filtering using this file.
soft_masking all boolean true Apply filtering locations as soft masks (i.e., only for finding
initial matches).
lcase_masking all flag N/A Use lower case filtering in query and subject sequence(s).
db_soft_mask all integer none Filtering algorithm ID to apply to the BLAST database as soft
mask (i.e., only for finding initial matches).
db_hard_mask all integer none Filtering algorithm ID to apply to the BLAST database as
hard mask (i.e., sequence is masked for all phases of search).
80 BLAST® Command Line Applications User Manual
template_type dc-megablast string coding Discontiguous MegaBLAST template type. Allowed values
are coding, optimal and coding_and_optimal.
use_index megablast boolean false Use MegaBLAST database index. Indices may be created
with the makembindex application.
xdrop_ungap all real 20 Heuristic value (in bits) for ungapped extensions.
xdrop_gap all real 30 Heuristic value (in bits) for preliminary gapped extensions.
xdrop_gap_final all real 100 Heuristic value (in bits) for final gapped alignment.
min_raw_gapped_score all integer none Minimum raw gapped score to keep an alignment in the
preliminary gapped and trace-back stages. Normally set
based upon expect value.
window_size dc-megablast integer 40 Multiple hits window size, use 0 to specify 1-hit algorithm
Table C3: blastp application options. The blastp application searches a protein sequence against protein subject sequences or a protein
database. An option of type “flag” takes no arguments, but if present the argument is true. Three different tasks are supported: 1.)
“blastp”, for standard protein-protein comparisons, 2.) “blastp-short”, optimized for query sequences shorter than 30 residues, and 3.)
“blastp-fast”, a faster version that uses a larger word-size per https://www.ncbi.nlm.nih.gov/pubmed/17921491. This table reflects the
2.2.27 BLAST+ release.
option task type default value description and notes
word_size blastp integer 3 Word size of initial match. Valid word sizes are 2-7.
threshold blastp integer 11 Minimum score to add a word to the BLAST lookup table.
threshold blastp-short integer 16 Minimum score to add a word to the BLAST lookup table.
Threshold Blastp-fast Integer 21 Minimum score to add a word to the BLAST lookup table.
0 or F or f: no composition-based statistics
D or d: default (equivalent to 2)
0 or F or f: no composition-based statistics
seg all string no Filter query sequence with SEG (Format: 'yes', 'window locut hicut', or
'no' to disable).
soft_masking blastp boolean false Apply filtering locations as soft masks (i.e., only for finding initial
matches).
lcase_masking all flag N/A Use lower case filtering in query and subject sequence(s).
db_soft_mask all integer none Filtering algorithm ID to apply to the BLAST database as soft mask
(i.e., only for finding initial matches).
db_hard_mask all integer none Filtering algorithm ID to apply to the BLAST database as hard mask
(i.e., sequence is masked for all phases of search).
xdrop_gap_final all real 25 Heuristic value (in bits) for final gapped alignment/
window_size Blastp and blastp- integer 40 Multiple hits window size, use 0 to specify 1-hit algorithm.
fast
window_size blastp-short integer 15 Multiple hits window size, use 0 to specify 1-hit algorithm.
Table C4: blastx application options. The blastx application translates a nucleotide query and searches it against protein subject
sequences or a protein database. Two different tasks are supported: 1.) “blastx” for standard translated nucleotide-protein comparison
and 2.) “blastx-fast”, a faster version that uses a larger word-size based on https://www.ncbi.nlm.nih.gov/pubmed/17921491.
option task type default value description and notes
word_size Blastx integer 3 Word size for initial match. Valid word sizes are 2-7.
threshold Blastx integer 12 Minimum score to add a word to the BLAST lookup table.
Appendices 83
threshold Blastx-fast Integer 21 Minimum score to add a word to the BLAST lookup table.
seg All string 12 2.2 2.5 Filter query sequence with SEG (Format: 'yes', 'window locut hicut', or 'no'
to disable).
soft_masking all boolean false Apply filtering locations as soft masks (i.e., only for finding initial matches).
lcase_masking all flag N/A Use lower case filtering in query and subject sequence(s).
db_soft_mask all integer none Filtering algorithm ID to apply to the BLAST database as soft mask (i.e.,
only for finding initial matches).
db_hard_mask all integer none Filtering algorithm ID to apply to the BLAST database as hard mask (i.e.,
sequence is masked for all phases of search).
xdrop_gap_final all real 25 Heuristic value (in bits) for final gapped alignment.
window_size all integer 40 Multiple hits window size, use 0 to specify 1-hit algorithm.
strand all string both Query strand(s) to search against database/subject. Choice of both, minus,
or plus.
max_intron_length all integer 0 Length of the largest intron allowed in a translated nucleotide sequence
when linking multiple distinct alignments (a negative value disables
linking).
D or d: default (equivalent to 2)
0 or F or f: no composition-based statistics
Default = `2'
84 BLAST® Command Line Applications User Manual
Table C5: tblastn application options. The tblastn application searches a protein query against nucleotide subject sequences or a
nucleotide database translated at search time. Two different tasks are supported: 1.) “tblastn” for a standard protein-translated
nucleotide comparison and 2.) “tblastn-fast” for a faster version with a larger word-size based on https://www.ncbi.nlm.nih.gov/
pubmed/17921491.
option task type default value description and notes
word_size tblastn integer 3 Word size for initial match. Valid word sizes are 2-7.
threshold tblastn integer 13 Minimum score to add a word to the BLAST lookup table.
threshold tblastn-fast Integer 21 Minimum score to add a word to the BLAST lookup table.
seg All string 12 2.2 2.5 Filter query sequence with SEG (Format: 'yes', 'window locut hicut', or 'no'
to disable).
soft_masking All boolean false Apply filtering locations as soft masks (i.e., only for finding initial matches).
lcase_masking All flag N/A Use lower case filtering in query and subject sequence(s).
db_soft_mask All integer none Filtering algorithm ID to apply to the BLAST database as soft mask (i.e.,
only for finding initial matches).
db_hard_mask All integer none Filtering algorithm ID to apply to the BLAST database as hard mask (i.e.,
sequence is masked for all phases of search).
xdrop_gap_final All real 25 Heuristic value (in bits) for final gapped alignment.
window_size All integer 40 Multiple hits window size, use 0 to specify 1-hit algorithm.
db_gen_code All integer 1 Genetic code to translate subject sequences, see ftp://ftp.ncbi.nih.gov/
entrez/misc/data/gc.prt
max_intron_length All integer 0 Length of the largest intron allowed in a translated nucleotide sequence
when linking multiple distinct alignments (a negative value disables
linking).
Appendices 85
D or d: default (equivalent to 2)
0 or F or f: no composition-based statistics
Default = `2'
Table C6: tblastx application options. The tblastx application searches a translated nucleotide query against translated nucleotide
subject sequences or a translated nucleotide database. An option of type “flag” takes no arguments, but if present the argument is true.
This table reflects the 2.2.27 BLAST+ release. Only ungapped searches are supported for tblastx.
option type default value description and notes
threshold integer 13 Minimum word score to add the word to the BLAST lookup table.
seg string 12 2.2 2.5 Filter query sequence with SEG (Format: 'yes', 'window locut hicut', or 'no' to disable).
soft_masking boolean false Apply filtering locations as soft masks (i.e., only for finding initial matches).
lcase_masking flag N/A Use lower case filtering in query and subject sequence(s).
db_soft_mask integer none Filtering algorithm ID to apply to the BLAST database as soft mask (i.e., only for finding
initial matches).
db_hard_mask integer none Filtering algorithm ID to apply to the BLAST database as hard mask (i.e., sequence is
masked for all phases of search).
strand string both Query strand(s) to search against database subject sequences. Choice of both, minus, or
plus.
max_intron_length integer 0 Length of the largest intron allowed in a translated nucleotide sequence when linking
multiple distinct alignments (a negative value disables linking)
Table C7: rpsblast application options. The rpsblast application searches a protein query against the conserved domain database
(CDD), which is a set of protein profiles. Many of the common options such as matrix or word threshold are set when the CDD is built
and cannot be changed by the rpsblast application. A search ready CDD can be downloaded from ftp://ftp.ncbi.nih.gov/pub/
mmdb/cdd/
Option Type Default Description and notes
value
window_size integer 40 Multiple hits window size, use 0 to specify 1-hit algorithm.
xdrop_ungap real 15 Heuristic value (in bits) for ungapped extensions
xdrop_gap real 25 Heuristic value (in bits) for preliminary gapped extensions.
xdrop_gap_final real 40 Heuristic value (in bits) for final gapped alignment.
seg string 12 2.2 2.5 Filter query sequence with SEG (Format: 'yes', 'window locut hicut', or 'no' to disable).
soft_masking boolean false Apply filtering locations as soft masks (i.e., only for finding initial matches).
mt_mode integer 0 Set to 1 if a large number of queries are to be searched and you wish to use multiple
threads, as specified by the num_threads argument.
comp_based_stats integer 2 Use composition-based statistics for rpsblast:
D or d: default (equivalent to 2)
0 or F or f: no composition-based statistics
1: Composition-based statistics as in NAR 29:2994-3005, 2001
2 or T or t : Composition-based score adjustment as in Bioinformatics
21:902-911, 2005, conditioned on sequence properties
3: Composition-based score adjustment as in Bioinformatics 21:902-911, 2005,
unconditionally
Default = `2'
Table C8: Makeblastdb application options. This application builds a BLAST database. An option of type “flag” takes no arguments, but
if present the argument is true. Starting with the 2.10.0 release, makeblastdb produces version 5 databases by default, which uses
LMDB. LMDB requires virtual memory (at least 600 GB, but 800 GB is recommended) to build an index. If makeblastdb cannot access
enough virtual memory, it will produce a message containing the string “mdb_env_open”. Virtual memory is just that (virtual) and
doesn’t depend on the hardware in your system. In general, we recommend that BLAST users simply set the virtual memory to
unlimited. The other alternative is to use an environment variable (BLASTDB_LMDB_MAP_SIZE) to set the required virtual memory
lower, but this runs the risk of LMDB not being able to complete indexing the database. For a smaller database (tens of millions of
letters) it may be possible to use a value of 100 million.
option type default value Description and notes
input_type string fasta Input file type, it may be any of the following:
dbtype string prot Molecule type of input, values can be nucl or prot.
title string none Title for BLAST database. If not set, the input file name will be used.
parse_seqids flag N/A Parse bar delimited sequence identifiers (e.g., gi|129295) in FASTA input.
mask_data string none Comma-separated list of input files containing masking data as produced by NCBI
masking applications (e.g. dustmasker, segmasker, windowmasker).
out string input file name Name of BLAST database to be created. Input file name is used if none provided. This field
is required if input consists of multiple files.
max_file_size string 1GB Maximum file size to use for BLAST database. 4GB is the maximum supported by the
database structure.
blastdb_version integer 5 Version 5 (taxonomy aware) is the default starting with the 2.10.0 release. Value must be 4
or 5.
taxid_map string none File with two columns mapping sequence ID to the taxonomy ID. The first column is the
sequence ID represented as one of:
The second column should be the NCBI taxonomy ID (e.g., 9606 for human).
Table C9: Makeprofiledb application options. This application builds an RPS-BLAST database. An option of type “flag” takes no
arguments, but if present the argument is true. COBALT (a multiple sequence alignment program) and DELTA-BLAST both use RPS-
88 BLAST® Command Line Applications User Manual
BLAST searches as part of their processing but use specialized versions of the database. This application can build databases for
COBALT, DELTA-BLAST, and a standard RPS-BLAST search. The “dbtype” option (see entry in table) determines which flavor of the
database is built.
option type default value Description and notes
in string stdin Input file that contains a list of scoremat files (delimited by space, tab, or newline)
title string none Title for RPS-BLAST database. If not set, the input file name will be used.
out string input file name Name of BLAST database to be created. Input file name is used if none provided.
max_file_size string 1GB Maximum file size to use for BLAST database.
dbtype string rps Specifies use for RPSBLAST db. One of rps, cobalt, or delta.
gapopen integer none Cost to open a gap. Used only if scoremat files do not contain PSSM scores, otherwise
ignored.
gapextend integer none Cost to extend a gap by one residue. Used only if scoremat files do not contain PSSM
scores, otherwise ignored.
matrix string BLOSUM62 Matrix to use in constructing PSSM. One of BLOSUM45, BLOSUM50, BLOSUM62,
BLOSUM80, BLOSUM90, PAM250, PAM30 or PAM70. Used only if scoremat files do not
contain PSSM scores, otherwise ignored.
obsr_threshold real 6 Exclude domains with maximum number of independent observations below this value
(for use in DELTA-BLAST searches).
exclude_invalid real true Exclude domains that do not pass validation test (for use in DELTA-BLAST searches).
max_smp_vol integer 2500 Maximum number of SMP files per DB volume. Increasing this number will decrease the
number of BLAST database volumes produced.
taxid_map string none File with two columns mapping sequence ID to the taxonomy ID. The first column is the
sequence ID represented as one of:
The second column should be the NCBI taxonomy ID (e.g., 9606 for human).
Table C10: Blastdbcmd application options. This application reads a BLAST database and produces reports.
option type default value description and notes
dbtype string guess Molecule type stored in BLAST database, one of nucl, prot, or guess.
entry string none Comma-delimited search string(s) of sequence identifiers: e.g.: 555, AC147927, 'gnl|
dbname|tag', or 'all' to select all sequences in the database
entry_batch string none Input file for batch processing. The format requires one entry per line; each line should
begin with the sequence ID followed by any of the following optional specifiers (in any
order): range (format: ‘from-to’, inclusive in 1-offsets), strand (‘plus’ or ‘minus’), or
masking algorithm ID (integer value representing the available masking algorithm).
Omitting the ending range (e.g.: ‘10-‘) is supported, but there should not be any spaces
around the ‘-‘.
strand string plus Strand of nucleotide sequence to extract. Choice of plus or minus.
mask_sequence_with string none Produce lower-case masked FASTA using the algorithm IDs specified.
outfmt string %f Output format, where the available format specifiers are:
%a means accession
%g means gi
%T means taxid
%P means PIG
ctrl_a flag N/A Use Ctrl-A as the non-redundant definition line separator.
Table C11: Makembindex application options. The indexed databases created by makembindex are used by production MegaBLAST
software and by a new srsearch utility designed to quickly search for nearly exact matches (up to one mismatch) of short queries against
a genomic database. When a FASTA formatted file is used as the input, then masking by lower case letters is incorporated in the index.
Makembindex can currently build two types of indices, called “old style” and “new style” indexing. The NCBI offers full support for the
new style and has deprecated the old style. A MegaBLAST search with a new style index requires that both the index and the
corresponding BLAST database be present. The index structure is described in PMID:18567917. Please cite this paper in any
publication that uses makembindex.
option type default value Description and notes
input string stdin Input file name or BLAST database name, depending on the value of the iformat parameter.
For FASTA formatted input, this parameter is optional and defaults to the program's
standard input stream.
output string none The resulting index name. The index itself can consist of multiple files, called volumes, called
<index_name>.00.idx, <index_name>.01.idx,...
iformat string fasta The input format selector. Possible values are 'fasta' and 'blastdb'.
old_style_index boolean false The old_style_index is no longer supported. If set to 'false' the new style index is created.
New style indices require a BLAST database as input (use -iformat blastdb), which can be
downloaded from the NCBI FTP site or created with makeblastdb. The option -output is
ignored for a new style index. New style indices are always created at the same location as
the corresponding BLAST database.
db_mask integer None Exclude masked regions of BLAST db from the index. Use makeblastdb to discover the
algorithm ID to be used as input for this argument.
legacy boolean true This is a compatibility feature to support current production MegaBLAST. If true, then -
stride, -nmer, and -ws_hint are ignored. The legacy format must be used for BLAST.
ws_hint integer 28 This is an optimization hint for makembindex that indicates an expected minimum match
size in searches that use the index. If n is the value of -nmer parameter and s is the value of –
stride parameter, then the value of -ws_hint must be at least n + s - 1.
stride integer 5 makembindex will index every stride-th N-mer of the database.
Table D1: Supported reward/penalty values and gap costs for the blastn application. The left-most column presents the supported
reward/penalty values. The middle column presents pairs of numbers for the cost to open and extend a gap for each reward/penalty
92 BLAST® Command Line Applications User Manual
value. Blastn also supports gap costs more stringent than those listed (e.g., for reward/penalty of 1/-3 gap costs of 5/2 or 500/2 are
supported). The reward/penalty values are ordered from most to least stringent, with the more stringent values better suited for
alignments with high sequence identity. The default megaBLAST gap costs are shown in the right-most column. Accurate statistics for
these default megaBLAST gap costs can only be calculated for the most stringent reward/penalty values, but the values listed in the
middle column can always be used.
reward/penalty gap costs (open/extend) default MegaBLAST gap costs (open/extend)
1/-5 3/3 0/5.5
1/-4 1/2, 0/2, 2/1, 1/1 0/4.5
2/-7 2/4, 0/4, 4/2, 2/2 0/8
1/-3 2/2, 1/2, 0/2, 2/1, 1/1 0/3.5
2/-5 2/4, 0/4, 4/2, 2/2 0/6
1/-2 2/2, 1/2, 0/2, 3/1, 2/1, 1/1 0/2.5
2/-3 4/4, 2/4, 0/4, 3/3, 6/2, 5/2, 4/2, 2/2 0/4
3/-4 6/3, 5/3, 4/3, 6/2, 5/2, 4/2 N/A
4/-5 6/5, 5/5, 4/5, 3/5 N/A
1/-1 3/2, 2/2, 1/2, 0/2, 4/1, 3/1, 2/1 N/A
3/-2 5/5 N/A
5/-4 10/6, 8/6 N/A
Gap Costs
The raw score of an alignment is the sum of the scores for aligning pairs of residues and the scores for gaps.
Gapped BLAST and PSI-BLAST use "affine gap costs" which charge the score -a for the existence of a gap, and
the score -b for each residue in the gap. Thus a gap of k residues receives a total score of -(a+bk); specifically, a
gap of length 1 receives the score -(a+b).
Lambda Ratio
To convert a raw score S into a normalized score S' expressed in bits, one uses the formula S' = (lambda*S - ln
K)/(ln 2), where lambda and K are parameters dependent upon the scoring system (substitution matrix and gap
costs) employed [7-9]. For determining S', the more important of these parameters is lambda. The "lambda ratio"
quoted here is the ratio of the lambda for the given scoring system to that for one using the same substitution
scores, but with infinite gap costs [8]. This ratio indicates what proportion of information in an ungapped
alignment must be sacrificed in the hope of improving its score through extension using gaps. We have found
empirically that the most effective gap costs tend to be those with lambda ratios in the range 0.8 to 0.9.
References
1. Altschul S.F. Amino acid substitution matrices from an information theoretic perspective. J. Mol. Biol.
1991;219:555–565. PubMed PMID: 2051488.
2. States D.J., Gish W., Altschul S.F. Improved sensitivity of nucleic acid database searches using application-
specific scoring matrices. Methods. 1991;3:66–70.
3. Altschul S.F. A protein alignment scoring system sensitive at all evolutionary distances. J. Mol. Evol.
1993;36:290–300. PubMed PMID: 8483166.
4. Henikoff S., Henikoff J.G. Amino acid substitution matrices from protein blocks. Proc. Natl. Acad. Sci. USA.
1992;89:10915–10919. PubMed PMID: 1438297.
5. Dayhoff, M.O., Schwartz, R.M. & Orcutt, B.C. (1978) "A model of evolutionary change in proteins." In "Atlas
of Protein Sequence and Structure, vol. 5, suppl. 3," M.O. Dayhoff (ed.), pp. 345-352, Natl. Biomed. Res.
Found., Washington, DC.
6. Schwartz, R.M. & Dayhoff, M.O. (1978) "Matrices for detecting distant relationships." In "Atlas of Protein
Sequence and Structure, vol. 5, suppl. 3," M.O. Dayhoff (ed.), pp. 353-358, Natl. Biomed. Res. Found.,
Washington, DC.
7. Karlin S., Altschul S.F. Methods for assessing the statistical significance of molecular sequence features by
using general scoring schemes. Proc. Natl. Acad. Sci. USA. 1990;87:2264–2268. PubMed PMID: 2315319.
8. Altschul S.F., Gish W. Local alignment statistics. Meth. Enzymol. 1996;266:460–480. PubMed PMID:
8743700.
9. Altschul S.F., Madden T.L., Schäffer A.A., Zhang J., Zhang Z., Miller W., Lipman D.J. Gapped BLAST and
PSI-BLAST: a new generation of protein database search programs. Nucleic Acids Res. 1997;25:3389–3402.
PubMed PMID: 9254694.
Outline
A. Read in user query and preprocess (mask for low-complexity, etc.)
B. Read user options and set parameters for the search. This includes examining how many matches
(database sequences) the user wants returned and the expect value. If the user wants N database
sequences returned and sets an expect value of E, then:
1. For Composition-based statistics (CBS), set an (internal) maximum limit of N_i=2*N+50
database sequences and an internal expect value of E_i = 5*E. CBS applies only to protein-protein
comparisons and is available for BLASTP, BLASTX, TBLASTN, RPSBLAST, and RPSTBLASTN.
2. Otherwise, set a maximum limit of N_i=MAX(MIN(2*N, N+50),10) database sequences.
C. Loop over every sequence in the database, performing the following actions:
1. Scan for initial matching word hits. If an initial hit is found, then move on to step 2, otherwise
move on to next sequence. Example initial matching word hits are:
a. 11 bases exact match for BLASTN.
b. 28 bases exact match for MegaBLAST
c. 3 residue match with score above threshold for BLAST[PX]/TBLASTN (default requires 2
word hits on a diagonal)
d. 6 residue match with score above threshold for BLAST[PX]/TBLASTN for fast task “blastp-
fast” etc. (default requires 2 on diagonal)
2. Perform a gap free extension based on the initial word hits. If this extension has a score above S_g
(set so that about one in 50 database sequences pass) then move on to step 3. Otherwise move on
to next sequence.
3. Perform a gapped extension based on the gap free extension. This gapped extension does not
collect traceback information, but only the extent of the alignment and the resulting score
(making it fast). This gapped extension uses a modified dynamic programming algorithm that
only explores a limited space based on a parameter called X_g. If the resulting alignment passes
the score cutoff (determined by expect value) move on to next step, otherwise move on to next
sequence.
4. Save the result for further processing unless there are already N_i better matching sequences
saved. Save the results in order of significance, keeping the best N_i thus far. Move on to next
sequence.
D. For each entry in the list saved in step C4 above:
1. Perform a gapped alignment with traceback (i.e., collect score, extent, position of indels, etc.)
using an X_fg that is larger than X_g. The larger X_fg means that the score and ranking of a match
may change. If CBS, then also adjust the score and expect value based on the composition of the
subject sequence (the composition of the query is always considered). This may change the score
and ranking of a match, sometimes dramatically.
2. Add the resulting match to a new ordered list. A tie (two matches with identical score and expect
value) is broken by the order of the sequences in the database. Almost every entry processed in the
last step results in a significant match, but an alignment calculated with CBS may become much
less statistically significant and will no longer be saved.
E. Format a report based on the list saved in D2:
1. Discard the N_i-N least significant matches.
2. Print results for the first N matches.
The retention of N_i > N matches through the internals of BLAST is intended to ensure that if some matches
become more or less significant, in the last phase of constructing the alignment, that BLAST will still show the
user the most relevant matches. For CBS, we increase N_i by a larger amount than for standard gapped BLAST,
as the application of CBS may result in a larger change in the significance of a match. For the same reason, the
internal expect value is also increased from the user requested value if CBS is requested.
Appendices 95
Figure 1: Outline of the BLAST process. A letter and number (e.g., C3) refers to a step in the outline.