0

I made a phylotree using .get_topology on a list, but I cannot add the scientific names and rank to the nodes. Specifically :

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)

I tried using :

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

But it returns empty dictionaries. I want the nodes to have their ranks, sci names and tax ids under corresponding attributes. What am I doing wrong?

Thanks, Arash

1 Answers1

0

OK, I figured the answer out by try-and-error. from 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')

This will annotate the tree and you can check the annotations by traversing through the nodes:

 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)