change the species feature of a PhyloNode object

17 views
Skip to first unread message

Jolien van Hooff

unread,
Dec 22, 2020, 5:05:52 AM12/22/20
to The ETE toolkit
Hi all,

I probably have a very basic question, but thus far I could not find the answer in the documentation nor this mailinglist. I was wondering, for a PhyloNode object, how I could update the species name.

Somehow, if I apply node.add_feature("species", "newname"), the result represented by node.species still returns the old value. The same holds for node.add_features(species="newname").

However, both methods perfectly enable me to change the name of the node itself (in this case, of the sequence, since it is a terminal leaf in a gene tree), with 'name' as the feature referred to.

Thanks in advance for your help!

Jolien

Salvador Capella

unread,
Dec 22, 2020, 6:05:49 AM12/22/20
to eteto...@googlegroups.com
Hi Jolien,

If I'm not mistaken, species is one of the default attributes of the PhyloNode.
Thus, you can update the species attribute by doing something like PhyloNode.species = new_species_name.

Hope it helps,

S

--
You received this message because you are subscribed to the Google Groups "The ETE toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etetoolkit+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/etetoolkit/92554684-c8f0-47db-a673-294dc9cc8e09o%40googlegroups.com.

j.j.e.v...@gmail.com

unread,
Dec 22, 2020, 10:09:25 AM12/22/20
to The ETE toolkit
Hi Salvador,

Thanks a lot for your quick reply!

Yes, I also think the species feature is automatically generated for each PhyloNode object, just like the name itself, for example (as indicated here, where one reads that by default it uses the first 3 characters of the name as species). Updating via PhyloNode.species = species did not work either. However, for the 'name' feature, this did work, just as the add_feature(s) methods did.

It seems difficult to override the function that defines the species names,  which I observed since I (to an ancestor of the node I was trying to change the species of), applied ancestor.set_species_naming_function(parse_species_name). If I were to change the name, the species seems to change according to this function, that is. Again, after that changing only the species names of a particular node with any of the options (add features, directly renaming the attribute as you suggested).

I can find a workaround, I realised, by giving this specific node another naming function, but I thought it might be more straightforward to be able to change it by one of the mentioned methods.

Cheers,
Jolien

p.s. I'm not sure whether this is the best place to report this, but I encountered a (very tiny!) typo in the Reference Guide: as you may spot here, some referrals to 'get_descendant_evol_events' method are written as 'get_descendants_evol_events'.

Jaime Huerta Cepas

unread,
Dec 22, 2020, 11:24:46 AM12/22/20
to eteto...@googlegroups.com

j.j.e.v...@gmail.com

unread,
Dec 23, 2020, 4:20:05 AM12/23/20
to The ETE toolkit
Hi Jaime,

Thank you for pointing me to that option. It might indeed work for me! However, possibly I'd ideally work with a function for the entire tree and turn it off for specific leafs/nodes within it, but I think it should be able to find a workaround.

Thanks for your help, both!

Jolien
Reply all
Reply to author
Forward
0 new messages