生信思路

NR | 拆分库

2023-08-29  本文已影响0人  iBioinformatics

https://cloud.tencent.com/developer/article/1842788
https://www.jianshu.com/p/d28f38db248d
https://www.cnblogs.com/jessepeng/p/13736609.html
https://www.gaptech.cn/docs/2f325e75-57dd-4faa-8358-8d2de4ccc88d/
https://www.jianshu.com/p/1d6edfcb4110

目录
1.准备本地数据库文件

2.按物种拆分NR库

一、准备本地数据库文件

NRTaxonomy数据库都是NCBI的子数据库,会提供比较全面的对应关系。在本地数据库按物种拆分的话,必须下载这两个数据库的文件。

1、NR 库下载

ftp下载地址:ftp://ftp.ncbi.nlm.nih.gov/blast/db/FASTA
NR数据库更新是相当频繁的,如果追求新,估计每个月甚至每周就重新下一次,但它又非常大,对于商业流程使用不可能更新得这么频繁,可以半年或一年更新一次。

2 、Taxonomy数据库下载

ftp下载地址:ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/
同样,taxonomy更新也很快。我们分库需要用到两个文件,

(1)accession2taxid中的prot.accession2taxid文件

它提供了nt/nr中accession号与物种分类taxid的对应关系,文件中第一列是accession号,第三列是对应物种的taxid号。(也有GI号,2016年以前大家用的是GI和taxid的对应文件,现在该文件已淘汰)。其格式为:

accession       accession.version       taxid   gi
A0A009IHW8      A0A009IHW8.1    1310613 1835922267
A0A011QK89      A0A011QK89.1    327160  2203519076
(2)另一个是taxdump文件夹里面的names.dmpdivision.dmp

里面包含了物种层级和物种名称等文件。解压后其中最关键的是names.dmpnodes.dmp文件。

(a) names.dmp 是\t和|符号分隔的文件,提供了taxid之间的物种分类进化树信息,

Taxonomy names file (names.dmp):
        tax_id                                  -- the id of node associated with this name
        name_txt                                -- name itself
        unique name                             -- the unique variant of this name if name not unique
        name class                              -- (synonym, common name, ...)
1       |       all     |               |       synonym |
1       |       root    |               |       scientific name |
2       |       Bacteria        |       Bacteria <bacteria>     |       scientific name |
2       |       bacteria        |               |       blast name      |
2       |       eubacteria      |               |       genbank common name     |
2       |       Monera  |       Monera <bacteria>       |       in-part |
2       |       Procaryotae     |       Procaryotae <bacteria>  |       in-part |
2       |       Prokaryotae     |       Prokaryotae <bacteria>  |       in-part |
2       |       Prokaryota      |       Prokaryota <bacteria>   |       in-part |
2       |       prokaryote      |       prokaryote <bacteria>   |       in-part |

(b)nodes.dmp示例(共13列,重要的也就taxid、上层级taxid、分类层级这前三列信息):

nodes.dmp file consists of taxonomy nodes. The description for each node includes the following
fields:
        tax_id                                  -- node id in GenBank taxonomy database
        parent tax_id                           -- parent node id in GenBank taxonomy database
        rank                                    -- rank of this node (superkingdom, kingdom, ...)
        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数据库本身分类的分法,即division.dmp文件,提供了divisionid和实际分类阶元的对应关系,第一列是divisionid,第二列是division名称,第三列是division的描述信息。如下所示,共12类物种。

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
0       |       BCT     |       Bacteria        |               |
1       |       INV     |       Invertebrates   |               |
2       |       MAM     |       Mammals |               |
3       |       PHG     |       Phages  |               |
4       |       PLN     |       Plants and Fungi        |               |
5       |       PRI     |       Primates        |               |
6       |       ROD     |       Rodents |               |
7       |       SYN     |       Synthetic and Chimeric  |               |
8       |       UNA     |       Unassigned      |       No species nodes should inherit this division assignment        |
9       |       VRL     |       Viruses |               |
10      |       VRT     |       Vertebrates     |               |
11      |       ENV     |       Environmental samples   |       Anonymous sequences cloned directly from the environment        |

readme.txt文件中解释了每个文件的每一列信息(注意|是列间隔,而非列本身):

*.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记录号)
    parent tax_id               -- parent node id in GenBank taxonomy database (上一层分类级别的tax_id)
    rank                    -- rank of this node (superkingdom, kingdom, ...)  该tax_id所处的分类层级)
    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的记录号)
    name_txt                -- name itself  (即对应tax_id号的物种名称)
    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

2.按物种拆分NR库

2.1 第一步:获得Aceesson和分类物种的对应关系

Invertebrates
Viruses




Plants 33090
Bacteria 2
Fungi 4751
Viruses 10239
Archaea 2157

Eukaryota为2759

根据以上的prot.accession2taxid.gznodes.dmpdivision.dmp文件,可通过编写脚本来获得accession和以上12类物种的对应关系。脚本略,自己写。假设结果文件命名为acc2sp.xls,格式如下:

2.2 第二步:获得分类物种的序列

根据acc2sp.xls这个文件以及NR总库序列文件nr.gz,我们就可以获得各类物种的序列信息了。当然除了taxonomy数据库本身分的这12类,我们也可以将它们合并来自定义子库。比如,

脚本自己写,最后得到的是各个子数据库的fasta序列文件。

2.3 第三步:建库和比对

blast或diamond比对工具进行序列数据库建库,后面比对选择对应的字库就可。
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

https://www.cnblogs.com/jessepeng/p/13736609.html

上一篇 下一篇

猜你喜欢

热点阅读