我在列表上使用.get_topology制作了一个phylotree,但是我无法将科学名称和等级添加到节点中。具体来说:
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名称和税收ID。我做错了什么?
谢谢, Arash的
答案 0 :(得分:0)
好的,我通过try-and-error找出答案。 来自ete3 import NCBITaxa,Tree
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)