Skip to content

to_nexus() does not emit compliant Nexus #1785

@jeetsukumaran

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Python APIIssue is about the Python APIbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions