Version 2 (modified by 2 years ago) ( diff ) | ,
---|
BLAST+ Quick Start Guide
For more complete information, visit NCBI:
- BLAST Command Line Applications User Manual
- BLAST+ Command-line options
- Local Blast Databases
- BLAST+: architecture and applications - BMC Bioinformatics 2009, 10:421
Examples are all for BLASTN but should work similarly for other BLAST+ commands (blastp, blastx, tblastn, and tblastx).
Note that on tak, 'blastn' is an alias for 'bsub blastn' (and other BLAST+ commands have corresponding aliases), so don't include 'bsub' as part of your command.
Tasks
Task | Description |
blastp | Traditional BLASTP to compare a protein query to a protein database |
blastp-short | BLASTP optimized for queries shorter than 30 residues |
blastn | Traditional BLASTN requiring an exact match of 11 |
blastn-short | BLASTN program optimized for sequences shorter than 50 bases |
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 |
Index or Make BLAST database
- Index a file of fasta sequences to create a custom blastn database, such as
>Sequence1 CTGTGACTTGAATGCAAATATCACCAAGAAGTTTGTGAGA >Sequence2 TGGGAGGGGCTTGGCGGGGAGTCCGTTGTTGAAGGATGGT ...
makeblastdb -dbtype nucl -parse_seqids -in myBlastDatabase.fa
Note that '–parse_seqids' is needed to be able to later extract sequences by their IDs, but using it drastically slows down indexing. For '-dbtype', choose nucl or prot.
- Specify a title for the database as well as an output file name
makeblastdb -in mature_mirna -title "micrornas $today" -parse_seqids -dbtype nucl -out mature_mirna
In the blast version 2.8 and later, you could also search for target sequences belong to certain species. The database should be in version 5 format. To create the databases, you need to specify '-parse_seqids -blastdb_version 5' and assign sequences to taxonomy ID with -taxid or -taxid_map, such as -taxid 9606 to assign all sequences to human. With '-taxid_map', you could assign a species to each sequence. It requires a text file with format: <SequenceId> <TaxonomyId><newline>
Run BLAST command
- Run a basic (but sensitive) blastn search. The default blastn command runs megablastn with a default word size of 28, whereas '-task blastn' uses a default word size of 11.
blastn -task blastn -query Query_seqs.fa -db myBlastDatabase.fa -evalue 0.05 -out Query_seqs.blastn.txt
- Run the blastn program optimized for sequences shorter than 50 bases (default word size of 7)
blastn -task blastn-short -query oligos.fa -db mature_mirna -out Query_seqs.blastn-short.txt
- Restrict search of database to include only the specified taxonomy IDs
# limit to human targets: blastn -query oligos.fa -db nt -taxids 9606 -out Query_seqs_to_human.txt # blast to all species under plant: blastn -query oligos.fa -db nt -taxidlist plant_speciesTaxids.txt -out Query_seqs_to_plants.txt # where plant_speciesTaxids.txt includes species taxonomy ids for all plants, which can be created with get_species_taxids.sh -t 3193 > plant_speciesTaxids.txt # where 3193 refers to plant
- Extract all sequence(s) from a blast database (in case you've deleted the original fasta file)
blastdbcmd -db myBlastDatabase.fa -entry all > myBlastDatabase.fa
Note that the output format for custom databases may be not quite fasta:
>lcl|Sequence0CTGTGACTTGAATGCAAATATCACCAAGAAGTTTGTGAGA >lcl|Sequence1TGGGAGGGGCTTGGCGGGGAGTCCGTTGTTGAAGGATGGT ...
- Extract one desired sequence ID from a blast database
blastdbcmd -db myBlastDatabase.fa -entry Sequence2 > Sequence2.fa
- Extract a list of desired sequence IDs from a blast database
blastdbcmd -db myBlastDatabase.fa -entry_batch IDs_to_get.txt > IDs_to_get.fa
where the format of IDs_to_get.txt (IDs of sequences you want to extract) is simply one ID per line, such as
Sequence2 Sequence3 Sequence4
and the output file is standard fasta.
- Get all command-line arguments
blastn -help
- Note that databases indexed for old-style blastall (using formatdb) work fine with blast+.
Using more restrictive BLAST options
Limiting or filtering hits can be done by the following options, which are all a bit different:
- -max_target_seqs => Maximum number of aligned sequences to keep (value of 5 or more is recommended; incompatible with num_descriptions, num_alignments)
- -num_descriptions => Number of database sequences to show one-line descriptions for
- -num_alignments => Number of database sequences to show alignments for
Requiring higher-confident hits than the defaults can also be useful
- -evalue => Expectation value (E) threshold for saving hits (default = 10); can be reduced to 0.1 or even 1e-10 (depending on the reason for doing the BLAST search)