Skip to content

to_nexus() does not emit compliant Nexus #1785

Closed

Description

@jeetsukumaran

As per the above, the Nexus string emitted by tskit is not standard Nexus and cannot be parsed by most software.

There are a two different problems.

(1) The TAXA block requires a DIMENSIONS NTAX=## statement.

(2) The list of taxon labels should be separated by SPACES, NOT by commas.

The TreeSequence.to_nexus() statement currently emits:

#NEXUS
BEGIN TAXA;
TAXLABELS tsk_0_1,tsk_1_1,tsk_2_1,tsk_3_1,tsk_4_0,tsk_5_0,tsk_6_0;
END;
BEGIN TREES;
	TREE tree0.00000000000000_100.00000000000000 = ((tsk_1_1:0.07086621911734,tsk_2_1:0.07086621911734)tsk_4_0:4.21281381972469,(tsk_0_1:1.20610709140453,tsk_3_1:1.20610709140453)tsk_5_0:3.07757294743750)tsk_6_0;
END;

Multiple program fail to parse this, including PAUP, BEAST, and, in fact, most phylogenetic programs and processing libraries.

Adding a DIMENSIONS statement and separating the taxon labels using spaces makes this not only compliant with standard Nexus, but also readable by most Nexus-supporting phylogenetic programs (whatever else their idiosyncracies! :) )

#NEXUS
BEGIN TAXA;
DIMENSIONS NTAX=7;
TAXLABELS tsk_0_1 tsk_1_1 tsk_2_1 tsk_3_1 tsk_4_0 tsk_5_0 tsk_6_0;
END;
BEGIN TREES;
	TREE tree0.00000000000000_100.00000000000000 = ((tsk_1_1:0.07086621911734,tsk_2_1:0.07086621911734)tsk_4_0:4.21281381972469,(tsk_0_1:1.20610709140453,tsk_3_1:1.20610709140453)tsk_5_0:3.07757294743750)tsk_6_0;
END;

Activity

  1. benjeffery commented on Oct 13, 2021

    @benjeffery
    Member

    @jeetsukumaran Thanks for this excellent issue report.

    Would you like to submit a PR to fix these issues? Contributions to tskit are recognised by authorship on the upcoming tskit paper.

  2. added
    bug
    Python API
    on Oct 13, 2021
  3. added this to the Python upcoming milestone on Oct 13, 2021
  4. jeromekelleher commented on Oct 13, 2021

    @jeromekelleher
    Member

    (No directly involved here, but related is #1671)

  5. jeetsukumaran commented on Oct 14, 2021

    @jeetsukumaran
    ContributorAuthor

    @jeetsukumaran Thanks for this excellent issue report.

    Would you like to submit a PR to fix these issues? Contributions to tskit are recognised by authorship on the upcoming tskit paper.

    That sounds great! I would love to contribute! I'll update you (and this issue) when I make progress

  6. jeromekelleher commented on Oct 22, 2021

    @jeromekelleher
    Member

    The basic issue was fixed in #1835. This issue can be closed when we add dendropy based tests of the functionality to confirm.

  7. added 3 commits that reference this issue on Oct 22, 2021
    6126b65
    f8960d6
    00967cb
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

    Python APIbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions