ete icon indicating copy to clipboard operation
ete copied to clipboard

root label not handled in tree.write()

Open cmayer opened this issue 2 years ago • 1 comments

I assign node labels to all nodes, including inner nodes: I traverse the tree with for n in t.traverse(): n.name = something

This assigns a name also to the root, which is what I want. If I call t.render("mytree.pdf", w=400, units="mm", tree_style=ts) with a ts that draws all node labels, according one of the examples in the docs: for each node I do name_face = AttrFace("name", fsize=10) faces.add_face_to_node(name_face, node, column=1, position="float")

the t.render also prints a node label at the root, which is what I want.

But the simple call: t.write(outfile="tree-with-node-labels-numbers.tre", format=8) does not write a label to the root. I tried different formats, but no luck. I am working with rooted trees and the tree that is written to the file is rooted. Do I miss something or is this a bug or a feature? I think it would be nice if the root node would also be written to the newick file if it is drawn with the show and render commands.

cmayer avatar Jan 20 '23 17:01 cmayer

You should use:

t.write(outfile="tree-with-node-labels-numbers.tre", format=8, format_root_node=True)

Gullumluvl avatar Apr 17 '23 20:04 Gullumluvl