Skip to content

newick() output should (optionally) allow root to be specified, if multiple roots exist #487

Closed

Description

@hyanwong

In the case of a ts.tree with multiple roots, we should probably output multiple trees, each terminated by a semicolon.

Activity

  1. jeromekelleher commented on May 30, 2018

    @jeromekelleher
    Member

    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?

  2. hyanwong commented on May 30, 2018

    @hyanwong
    MemberAuthor

    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.

  3. hyanwong commented on May 30, 2018

    @hyanwong
    MemberAuthor

    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))
    
  4. jeromekelleher commented on May 30, 2018

    @jeromekelleher
    Member

    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.

  5. hyanwong commented on May 30, 2018

    @hyanwong
    MemberAuthor

    Seems reasonable to me.

  6. 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
  7. added this to the Release 0.6.0 milestone on Jun 8, 2018
  8. added 2 commits that reference this issue on Jun 8, 2018
    0263f94
    87b6edf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions