网页
综合
更新时间 2026-11-17 09:02:56
Dealing with the NCBI Taxonomy database — ETE Toolkit - analysis and visualization of trees
自动蜘蛛
etetoolkit.org
正文约 2931 字
ETE’s ncbi_taxonomy module provides utilities to efficiently query a local copy of the NCBI Taxonomy database. The class NCBITaxonomy offers methods to convert from taxid to names (and vice versa), to fetch pruned topologies connecting a given set of species, or to download rank, names and lineage track information.
It is also fully integrated with PhyloTree instances through the PhyloNode.annotate_ncbi_taxa() method.
The first time you attempt to use NCBITaxa, ETE will detect that your local database is empty and it will attempt to download the latest NCBI taxonomy database (~300MB) and will store a parsed version of it in your home directory: ~/.etetoolkit/taxa.sqlite. All future imports of NCBITaxa will detect the local database and will skip this step.
Use the method :NCBITaxa:`update_taxonomy_database` to download and parse the latest database from the NCBI ftp site. Your current local database will be overwritten.
you can fetch species names, ranks and linage track information for your taxids using the following methods:
The so called get-translator-functions will return a dictionary converting between taxids and species names. Either species or linage names/taxids are accepted as input.
Other functions allow to extract further information using taxid numbers as a query.
And you can combine combine all at once:
Given a taxid or a taxa name from an internal node in the NCBI taxonomy tree, their descendants can be retrieved as follows:
Getting the NCBI taxonomy tree for a given set of species is one of the most useful ways to get all information at once. The method NCBITaxa.get_topology() allows to query your local NCBI database and extract the smallest tree that connects all your query taxids. It returns a normal ETE tree in which all nodes, internal or leaves, are annotated for lineage, scientific names, ranks, and so on.
If needed, all intermediate nodes connecting the species can also be kept in the tree:
NCBI taxonomy annotation consists of adding additional information to any internal a leaf node in a give user tree. Only an attribute containing the taxid associated to each node is required for the nodes in the query tree. The annotation process will add the following features to the nodes:
Note that, for internal nodes, taxid can be automatically inferred based on their sibling nodes. The easiest way to annotate a tree is to use a PhyloTree instance where the species name attribute is transparently used as the taxid attribute. Note that the :PhyloNode:`annotate_ncbi_taxa`: function will also return the used name, lineage and rank translators.
Remember that species names in PhyloTree instances are automatically extracted from leaf names. The parsing method can be easily adapted to any formatting:
Alternatively, you can also use the NCBITaxa.annotate_tree() function to annotate a custom tree instance.
© Copyright 2015, The ETE Toolkit Team. Last updated on Mar 18, 2016.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。