You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
newick() output should (optionally) allow root to be specified, if multiple roots exist #487
I agree with this, but I think we need to consider what downstream tools will do with such inputs? Do you have any idea what libraries like biopython and R toolkits will do with this input @hyanwong? Is the idea of a tree with multiple roots something that people consider in the newick-based toolchain?
I'm only familiar with DendroPy, which has a "TreeList" class for multiple semicolon-separated newick trees. However, it usually assumes these are different topologies, all with the same tips, rather than a set of broken-apart subtrees, so your point is well made.
One other possibility is to allow .newick() to take an optional argument specifying which root to use for the tree, so that we can iterate over tree.roots to output the tree(s) ourselves. The default would be to use roots[0].
for tree in ts.trees():
for root in tree.roots:
print(tree.newick(root))
Yes, this is the best strategy I think. Users can then twiddle the output as they like. If root is None, revert to the current semantics (raising an error if more than one root), and otherwise return the newick tree rooted at that node.
changed the title [-]newick() output should allow multiple roots[/-][+]newick() output should (optionally) allow root to be specified, if multiple roots exist[/+]on May 31, 2018
Activity
jeromekelleher commentedon May 30, 2018
I agree with this, but I think we need to consider what downstream tools will do with such inputs? Do you have any idea what libraries like biopython and R toolkits will do with this input @hyanwong? Is the idea of a tree with multiple roots something that people consider in the newick-based toolchain?
hyanwong commentedon May 30, 2018
I'm only familiar with DendroPy, which has a "TreeList" class for multiple semicolon-separated newick trees. However, it usually assumes these are different topologies, all with the same tips, rather than a set of broken-apart subtrees, so your point is well made.
hyanwong commentedon May 30, 2018
One other possibility is to allow .newick() to take an optional argument specifying which root to use for the tree, so that we can iterate over tree.roots to output the tree(s) ourselves. The default would be to use roots[0].
jeromekelleher commentedon May 30, 2018
Yes, this is the best strategy I think. Users can then twiddle the output as they like. If
rootis None, revert to the current semantics (raising an error if more than one root), and otherwise return the newick tree rooted at that node.hyanwong commentedon May 30, 2018
Seems reasonable to me.
[-]newick() output should allow multiple roots[/-][+]newick() output should (optionally) allow root to be specified, if multiple roots exist[/+]Added root argument to Tree.newick().
Added root argument to Tree.newick().