BLAST(Basic local alignment search tool),即基于局部比對算法的搜索工具
BLAST包括blastn, blastp, blastx, tblastn, tblastx等. 使用conda安裝即可,亦可使用源碼(https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+)。
想安裝某個特定版本可以使用
conda install -c bioconda blast==版本號
# blast安裝perl模塊的方法
conda isntall perl-digest-md5
BLAST的基本步驟
- 用makeblastdb為BLAST建立數據庫
- 選擇BLAST工具,blastn, blastp, blastx, tblastn, tblastx等
- 運行BLAST工具,在有必要的情況下還可以對輸出結果進行修飾以得到自己想要的結果格式
第一步 BLAST數據庫的構建
格式化蛋白質數據庫:
makeblastdb -in spinach.fa -parse_seqids -hash_index -out spinach_DB -dbtype prot
格式化核酸數據庫:
makeblastdb -in spinach.fa -parse_seqids -hash_index -out spinach_DB -dbtype nucl
#一般帶上-parse_seqids -hash_index
將基因組和想要構建的數據庫名字替換即可,一般我們做生物信息都會用本地BLAST,因此不介紹遠程數據庫。
第二步 選擇BLAST工具
- blastn nucleotide to nucleotide
- blastp protein to protein
- blastx translated nucleotide to protein
- tblastn protein to translated nucleotide
blastp的常用參數
-query 后接查詢序列的文件名稱;
-db 后接格式化好的數據庫名稱;
-out 后接要輸出的文件名稱及格式
blastn的常用參數
-db: 指定blast搜索用的數據庫
-query: 用來查詢的輸入序列,fasta格式
-out:輸出結果文件
-evalue: 設置e值cutoff
-max_target_seqs: 設置最多的目標序列匹配數
-num_threads:指定多少個cpu運行任務(依賴于你的系統,同于以前的-a參數)
-outfmt format "7 qacc sacc evalue length pident" :這個是新BLAST+中最叼的功能了,直接控制輸出格式,不用再用parser啦, 7表示帶注釋行的tab格式的輸出,可以自定義要輸出哪些內容,用空格分格跟在7的后面,并把所有的輸出控制用雙引號括起來,其中qacc查詢序列的acc,sacc表示目標序列的acc,evalue即是e值,length即是匹配的長度,pident即是序列相同的百分比,其他可用的特征(代碼塊中顯示)如下:
Formatting options
-outfmt <String>
alignment view options:
0 = pairwise,
1 = query-anchored showing identities,
2 = query-anchored no identities,
3 = flat query-anchored, show identities,
4 = flat query-anchored, no identities,
5 = XML Blast output,
6 = tabular,
7 = tabular with comment lines,
8 = Text ASN.1,
9 = Binary ASN.1
10 = Comma-separated values
11 = BLAST archive (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
Options 6, 7, and 10 can be additionally configured to produce
a custom format specified by space delimited format specifiers.
一般來說用的就是6、7、10、17,因為要通過覆蓋度和得分來篩選結果的話用這三種比較方便,而7的話是比6多了一些注釋部分,結果部分是一樣的。
qseqid means Query Seq-id
qgi means Query GI
qacc means Query accesion
sseqid means Subject Seq-id
sallseqid means All subject Seq-id(s), separated by a ';'
sgi means Subject GI
sallgi means All subject GIs
sacc means Subject accession
sallacc means All subject accessions
qstart means Start of alignment in query #這個位置在最起始為1,而不是0,注意這個位置和別的的計算未知的差別
qend means End of alignment in query
sstart means Start of alignment in subject #同理,這個也是最起始為1,不是0
send means End of alignment in subject
qseq means Aligned part of query sequence
sseq means Aligned part of subject sequence
evalue means Expect value
bitscore means Bit score
score means Raw score
length means Alignment length
pident means Percentage of identical matches
nident means Number of identical matches
mismatch means Number of mismatches
positive means Number of positive-scoring matches
gapopen means Number of gap openings
gaps means Total number of gaps
ppos means Percentage of positive-scoring matches
frames means Query and subject frames separated by a '/'
qframe means Query frame
sframe means Subject frame
第三步 運行BLAST
blastp
blastp -query spinach_1.fa -db spinach_DB -out spinach_blast
blastn
自己經常用的命令如下所示
blastn -task blastn -db datebase_name -query input_file -outfmt 6 -out output_file
blastn -task blastn -db database_name -query input_file -out output_file -evalue evalue -max_target_seqs num_sequences -num_threads int_value -outfmt format format_string
blastn -task blastn -db database_name -query input_file -out output_file -evalue evalue -max_target_seqs num_sequences -num_threads int_value -outfmt format " 6 qseqid sseqid pident length mismatch gapopen qstart qend sstart send qseq sseq evalue bitscore"
一般默認的使用輸出結果格式6的話輸出的結果文件的數據如下所示:
query acc.ver, subject acc.ver, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
注:第二條命令可以增加對應的qseq, sseq