| 1 | === BLAST+ Quick Start Guide === |
| 2 | |
| 3 | For more complete information, visit NCBI: |
| 4 | * [[http://www.ncbi.nlm.nih.gov/books/NBK1763/|BLAST Command Line Applications User Manual]] |
| 5 | * [[http://www.ncbi.nlm.nih.gov/books/NBK279675/ | BLAST+ Command-line options]] |
| 6 | * [[http://iona.wi.mit.edu/bio/databases/list.php | Local Blast Databases]] |
| 7 | * [[http://www.biomedcentral.com/1471-2105/10/421|BLAST+: architecture and applications]] - BMC Bioinformatics 2009, 10:421 |
| 8 | |
| 9 | **Examples are all for BLASTN but should work similarly for other BLAST+ commands (blastp, blastx, tblastn, and tblastx). ** |
| 10 | |
| 11 | |
| 12 | **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.** |
| 13 | |
| 14 | |
| 15 | === Tasks === |
| 16 | ||'''Task''' || '''Description''' || |
| 17 | ||blastp || Traditional BLASTP to compare a protein query to a protein database || |
| 18 | ||blastp-short || BLASTP optimized for queries shorter than 30 residues || |
| 19 | ||blastn || Traditional BLASTN requiring an exact match of 11 || |
| 20 | ||blastn-short || BLASTN program optimized for sequences shorter than 50 bases || |
| 21 | ||megablast || Traditional megablast used to find very similar (e.g., intraspecies or closely related species) sequences || |
| 22 | ||dc-megablast || Discontiguous megablast used to find more distant (e.g., interspecies) sequences || |
| 23 | |
| 24 | |
| 25 | === Index or Make BLAST database === |
| 26 | * Index a file of fasta sequences to create a custom blastn database, such as |
| 27 | |
| 28 | {{{ |
| 29 | >Sequence1 |
| 30 | CTGTGACTTGAATGCAAATATCACCAAGAAGTTTGTGAGA |
| 31 | >Sequence2 |
| 32 | TGGGAGGGGCTTGGCGGGGAGTCCGTTGTTGAAGGATGGT |
| 33 | ... |
| 34 | }}} |
| 35 | |
| 36 | |
| 37 | |
| 38 | {{{ |
| 39 | makeblastdb -dbtype nucl -parse_seqids -in myBlastDatabase.fa |
| 40 | }}} |
| 41 | |
| 42 | |
| 43 | 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'''. |
| 44 | |
| 45 | * Specify a title for the database as well as an output file name |
| 46 | |
| 47 | {{{ |
| 48 | makeblastdb -in mature_mirna -title "micrornas $today" -parse_seqids -dbtype nucl -out mature_mirna |
| 49 | }}} |
| 50 | |
| 51 | 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> |
| 52 | |
| 53 | |
| 54 | === Run BLAST command === |
| 55 | |
| 56 | * 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. |
| 57 | |
| 58 | {{{ |
| 59 | |
| 60 | |
| 61 | blastn -task blastn -query Query_seqs.fa -db myBlastDatabase.fa -evalue 0.05 -out Query_seqs.blastn.txt |
| 62 | }}} |
| 63 | |
| 64 | * Run the blastn program optimized for sequences shorter than 50 bases (default word size of 7) |
| 65 | |
| 66 | {{{ |
| 67 | blastn -task blastn-short -query oligos.fa -db mature_mirna -out Query_seqs.blastn-short.txt |
| 68 | }}} |
| 69 | |
| 70 | * Restrict search of database to include only the specified taxonomy IDs |
| 71 | {{{ |
| 72 | # limit to human targets: |
| 73 | blastn -query oligos.fa -db nt -taxids 9606 -out Query_seqs_to_human.txt |
| 74 | |
| 75 | # blast to all species under plant: |
| 76 | blastn -query oligos.fa -db nt -taxidlist plant_speciesTaxids.txt -out Query_seqs_to_plants.txt |
| 77 | # where plant_speciesTaxids.txt includes species taxonomy ids for all plants, which can be created with |
| 78 | get_species_taxids.sh -t 3193 > plant_speciesTaxids.txt |
| 79 | # where 3193 refers to plant |
| 80 | }}} |
| 81 | |
| 82 | * Extract all sequence(s) from a blast database (in case you've deleted the original fasta file) |
| 83 | |
| 84 | {{{ |
| 85 | blastdbcmd -db myBlastDatabase.fa -entry all > myBlastDatabase.fa |
| 86 | }}} |
| 87 | |
| 88 | Note that the output format for custom databases may be not quite fasta: |
| 89 | |
| 90 | |
| 91 | {{{ |
| 92 | >lcl|Sequence0CTGTGACTTGAATGCAAATATCACCAAGAAGTTTGTGAGA |
| 93 | >lcl|Sequence1TGGGAGGGGCTTGGCGGGGAGTCCGTTGTTGAAGGATGGT |
| 94 | ... |
| 95 | }}} |
| 96 | |
| 97 | |
| 98 | * Extract one desired sequence ID from a blast database |
| 99 | |
| 100 | {{{ |
| 101 | blastdbcmd -db myBlastDatabase.fa -entry Sequence2 > Sequence2.fa |
| 102 | }}} |
| 103 | |
| 104 | * Extract a list of desired sequence IDs from a blast database |
| 105 | |
| 106 | {{{ |
| 107 | blastdbcmd -db myBlastDatabase.fa -entry_batch IDs_to_get.txt > IDs_to_get.fa |
| 108 | }}} |
| 109 | |
| 110 | where the format of IDs_to_get.txt (IDs of sequences you want to extract) is simply one ID per line, such as |
| 111 | |
| 112 | |
| 113 | {{{ |
| 114 | Sequence2 |
| 115 | Sequence3 |
| 116 | Sequence4 |
| 117 | }}} |
| 118 | |
| 119 | and the output file is standard fasta. |
| 120 | |
| 121 | * Get all command-line arguments |
| 122 | |
| 123 | {{{ |
| 124 | blastn -help |
| 125 | }}} |
| 126 | |
| 127 | * Note that databases indexed for old-style blastall (using formatdb) work fine with blast+. |
| 128 | |
| 129 | === Filtering BLAST results=== |
| 130 | * Limiting or filtering hits: do not use max_target_seqs. Based on [[https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/bty833/5106166 | Misunderstood parameter of NCBI BLAST impacts the correctness of bioinformatics workflows]], this parameter does not return the top/best hit(s)! Instead, get all hits and filter downstream as needed. |
| 131 | |