0

我在列表中使用 .get_topology 创建了一个系统树,但我无法将科学名称和排名添加到节点。具体来说 :

from ete3 import NCBITaxa, Tree, TreeStyle, NodeStyle

Ltax = [561863, 333367, 518636, 1262999, 657322, 550540, 44012, 748224, 518636, 1309411]
ncbi = NCBITaxa()
t = ncbi.get_topology(Ltax, intermediate_nodes=False)

我尝试使用:

tax2names, tax2lineages, tax2rank = t.annotate_ncbi_taxa()
ncbi.annotate_tree(t, taxid_attr='name', tax2name=tax2names, tax2track=tax2lineages, tax2rank=tax2rank)

但它返回空字典。我希望节点在相应的属性下有他们的等级、sci 名称和税号。我究竟做错了什么?

谢谢,阿拉什

4

1 回答 1

0

好的,我通过试错法找到了答案。从 ete3 导入 NCBITaxa,树

Ltax = [561863, 333367, 518636, 1262999, 657322, 550540, 44012, 748224, 518636, 1309411]
ncbi = NCBITaxa()
t = ncbi.get_topology(Ltax, intermediate_nodes=False)
ncbi.annotate_tree(t, taxid_attr='name')

这将注释树,您可以通过遍历节点来检查注释:

 for node in t.iter_descendants("postorder"):

    #print(node.name)
    #print(node.species)
    #print(node.named_lineage)
    #print(node.lineage)
    #print(node.sci_name)
    print(node.rank)
于 2016-09-16T10:30:53.227 回答