niemasd / TreeSwift

TreeSwift: Fast tree module for Python 3
https://niema.net/TreeSwift
GNU General Public License v3.0
75 stars 14 forks source link

Reading in mutations #16

Closed pekarj closed 3 years ago

pekarj commented 3 years ago

Hi Niema,

The output of TreeTime lists mutations along branches, but TreeSwift does not seem to be able to read trees that include this information. Example nexus file attached.

Is it possible to have TreeSwift read in the mutations and assign them to the child node of a branch?

Thanks!

Best, Jonathan

timetree.nexus.txt

niemasd commented 3 years ago

Sure, thanks for pointing this out! I've found where the bug occurs (it's a bug with parsing Newick strings with multiple parameters on a given edge). I'll try to push an update with a fix ASAP

niemasd commented 3 years ago

Should be fixed in TreeSwift v1.1.15!

https://pypi.org/project/treeswift/1.1.15/

Given any node, you can access these attributes via the node's edge_params variable:

current_node.edge_params

I just store it as a string without the leading [ and trailing ], so you would need to parse it for your specific context

pekarj commented 3 years ago

Perfect. Thank you so much!