1.準(zhǔn)備本地?cái)?shù)據(jù)庫(kù)文件
NR(Non-Redundant Protein Sequence Database)
非冗余蛋白庫(kù)戏蔑,是所有GenBank+EMBL+DDBJ+PDB
中的非冗余蛋白序列迄汛。Taxonomy
物種分類(lèi)數(shù)據(jù)庫(kù),包括大于7萬(wàn)余個(gè)物種的名字和系譜,這些物種都至少在遺傳數(shù)據(jù)庫(kù)中有一條核酸或蛋白序列疗隶。NR
和Taxonomy
數(shù)據(jù)庫(kù)都是NCBI
的子數(shù)據(jù)庫(kù),會(huì)提供比較全面的對(duì)應(yīng)關(guān)系。在本地?cái)?shù)據(jù)庫(kù)按物種拆分的話关摇,必須下載這兩個(gè)數(shù)據(jù)庫(kù)的文件。
1.1 NR庫(kù)下載
ftp下載地址:ftp://ftp.ncbi.nlm.nih.gov/blast/db/FASTA
NR數(shù)據(jù)庫(kù)更新是相當(dāng)頻繁的命贴,如果追求新襟士,估計(jì)每個(gè)月甚至每周就重新下一次落包,但它又非常大部蛇,對(duì)于商業(yè)流程使用不可能更新得這么頻繁摊唇,可以半年或一年更新一次。
1.2 Taxonomy數(shù)據(jù)庫(kù)下載
ftp下載地址:ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/
同樣涯鲁,taxonomy更新也很快巷查。
我們分庫(kù)需要用到兩個(gè)文件,一個(gè)是
accession2taxid
中的prot.accession2taxid
文件:該文件將
accession
和taxid
關(guān)系對(duì)應(yīng)起來(lái)(也有GI號(hào)抹腿,2016年以前大家用的是GI和taxid的對(duì)應(yīng)文件岛请,現(xiàn)在該文件已淘汰)。其格式為:另一個(gè)是
taxdump
文件警绩,里面包含了物種層級(jí)和物種名稱(chēng)等文件崇败。解壓后文件:readme.txt
文件中解釋了每個(gè)文件的每一列信息(注意|是列間隔,而非列本身):
*.dmp files are bcp-like dump from GenBank taxonomy database.
General information.
Field terminator is "\t|\t"
Row terminator is "\t|\n"
nodes.dmp file consists of taxonomy nodes. The description for each node includes the following
fields:
tax_id -- node id in GenBank taxonomy database (Taxonomy記錄號(hào))
parent tax_id -- parent node id in GenBank taxonomy database (上一層分類(lèi)級(jí)別的tax_id)
rank -- rank of this node (superkingdom, kingdom, ...) 該tax_id所處的分類(lèi)層級(jí))
embl code -- locus-name prefix; not unique
division id -- see division.dmp file
inherited div flag (1 or 0) -- 1 if node inherits division from parent
genetic code id -- see gencode.dmp file
inherited GC flag (1 or 0) -- 1 if node inherits genetic code from parent
mitochondrial genetic code id -- see gencode.dmp file
inherited MGC flag (1 or 0) -- 1 if node inherits mitochondrial gencode from parent
GenBank hidden flag (1 or 0) -- 1 if name is suppressed in GenBank entry lineage
hidden subtree root flag (1 or 0) -- 1 if this subtree has no sequence data yet
comments -- free-text comments and citations
Taxonomy names file (names.dmp):
tax_id -- the id of node associated with this name (為taxonomy的記錄號(hào))
name_txt -- name itself (即對(duì)應(yīng)tax_id號(hào)的物種名稱(chēng))
unique name -- the unique variant of this name if name not unique
name class -- (synonym, common name, ...)
Divisions file (division.dmp):
division id -- taxonomy database division id
division cde -- GenBank division code (three characters)
division name -- e.g. BCT, PLN, VRT, MAM, PRI...
comments
Genetic codes file:
genetic code id -- GenBank genetic code id
abbreviation -- genetic code name abbreviation
name -- genetic code name
cde -- translation table for this genetic code
starts -- start codons for this genetic code
Deleted nodes file (delnodes.dmp):
tax_id -- deleted node id
Merged nodes file (merged.dmp):
old_tax_id -- id of nodes which has been merged
new_tax_id -- id of nodes which is result of merging
Citations file (citations.dmp):
cit_id -- the unique id of citation
cit_key -- citation key
pubmed_id -- unique id in PubMed database (0 if not in PubMed)
medline_id -- unique id in MedLine database (0 if not in MedLine)
url -- URL associated with citation
text -- any text (usually article name and authors).
-- The following characters are escaped in this text by a backslash:
-- newline (appear as "\n"),
-- tab character ("\t"),
-- double quotes ('\"'),
-- backslash character ("\\").
taxid_list -- list of node ids separated by a single space
其中最關(guān)鍵的是names.dmp
和nodes.dmp
文件肩祥。names.dmp
示例(共四列后室,重要的也就taxid和物種名的前兩列信息):
nodes.dmp
示例(共13列,重要的也就taxid混狠、上層級(jí)taxid岸霹、分類(lèi)層級(jí)這前三列信息):為了讓分類(lèi)更簡(jiǎn)單,我們按taxonomy數(shù)據(jù)庫(kù)本身分類(lèi)的分法将饺,即
division.dmp
文件贡避,共12類(lèi)物種。2.按物種拆分NR庫(kù)
2.1 第一步:獲得Aceesson和分類(lèi)物種的對(duì)應(yīng)關(guān)系
根據(jù)以上的prot.accession2taxid.gz
予弧、nodes.dmp
和division.dmp
文件刮吧,可通過(guò)編寫(xiě)腳本來(lái)獲得accession
和以上12類(lèi)物種的對(duì)應(yīng)關(guān)系。腳本略掖蛤,自己寫(xiě)皇筛。假設(shè)結(jié)果文件命名為acc2sp.xls
,格式如下:
2.2 第二步:獲得分類(lèi)物種的序列
根據(jù)acc2sp.xls
這個(gè)文件以及NR總庫(kù)序列文件nr.gz
坠七,我們就可以獲得各類(lèi)物種的序列信息了水醋。當(dāng)然除了taxonomy數(shù)據(jù)庫(kù)本身分的這12類(lèi),我們也可以將它們合并來(lái)自定義子庫(kù)彪置。比如這12類(lèi)中沒(méi)有動(dòng)物拄踪,我們可以將Invertebrates.fa、 Mammals.fa拳魁、 Primates.fa惶桐、 Rodents.fa 和Vertebrates.fa
合并為動(dòng)物作為一類(lèi),也可以將"Bacteria"、"fungi"姚糊、"Viruses"贿衍、"Phages"
和"Environmental.samples"
等合并為微生物作為一類(lèi)(這在宏組學(xué)注釋中常用)。當(dāng)然NR中也有這12類(lèi)中沒(méi)包含的序列救恨,我們可將其歸為unknown.fa
(不同于Unassigned.fa
贸辈,它是沒(méi)有物種信息)。
腳本自己寫(xiě)肠槽,最后得到的是各個(gè)子數(shù)據(jù)庫(kù)的fasta
序列文件擎淤。
2.3 第三步:建庫(kù)和比對(duì)
blast或diamond比對(duì)工具進(jìn)行序列數(shù)據(jù)庫(kù)建庫(kù),后面比對(duì)選擇對(duì)應(yīng)的字庫(kù)就可秸仙。
blastall:
formatdb -p T -i Plants.fa
blastall -i query.fa -d Plants.fa -o blastout.nr -p blastp -F F -m 7 -e 1e-5 -b 10 -v 10 -a 5
或diamond:
diamond makedb --in Plants.fa -d Plants.fa
diamond blastp --evalue 1e-5 --threads 4 --outfmt 5 -q query.fa -d Plants.fa.dmnd -o blastout.nr --seg no --max-target-seqs 20 --more-sensitive -b 0.5 --salltitles