This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

NEXUS (.nex, .nxs)

NEXUS phylogenetic file format.
Commonly used for storage and exchange of phylogenetic data.
Can store DNA and protein sequences, taxa distances, alignment scores, and phylogenetic trees.
ASCII format.
Allows user extensions.
Developed in the 1990s.
  • Import can read sequence data and distance matrices from NEXUS files.
  • Export converts sequence data to the NEXUS format.
  • Import imports DNA or protein sequences from a NEXUS file.
  • Export exports a sequence or list of sequences to the NEXUS file.
  • Import returns a list of strings representing the sequences stored in the file.
  • Export exports a character string representing a DNA or protein sequence to NEXUS.
  • Export exports multiple sequences.
  • Import imports the specified element from a NEXUS file.
  • Import imports multiple elements.
  • Export creates a NEXUS file by treating expr as specifying element elem.
  • Export treats each as specifying the corresponding .
  • Export exports expr with the specified option elements taken to have the specified values.
  • Export uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
"Elements"list of elements and options available in this file
"Rules"full list of rules for each element and option
"Options"list of rules for options, properties, and settings
  • Data representation elements:
"DistanceMatrix"distances between taxa given as a numerical matrix
"Sequence"sequences given as a list of strings
"Taxa"taxon names
  • Import uses the element by default.
  • Additional data elements:
"Data" and elements combined in a list
"LabeledData"list of rules for each taxon and sequence stored in the file
  • Mathematica uses the standard IUB/IUPAC abbreviations for nucleic acids and amino acids. See the reference page for "FASTA" for detailed information.
Import sequence data from a NEXUS file:
Import the taxon names and sequence data as a list of rules:
Export DNA sequences to the NEXUS format:
Export a pair of DNA sequences with explicit taxon names:
This returns the taxon names stored in the file along with a distance matrix:
Import taxon names and sequence data as pairs:
Import sequence data from a NEXUS file:
In[1]:=
Click for copyable input
Out[1]=
 
Import the taxon names and sequence data as a list of rules:
In[1]:=
Click for copyable input
Out[1]=
 
Export DNA sequences to the NEXUS format:
In[1]:=
Click for copyable input
Out[1]=
 
Export a pair of DNA sequences with explicit taxon names:
In[1]:=
Click for copyable input
Out[1]=
 
This returns the taxon names stored in the file along with a distance matrix:
In[1]:=
Click for copyable input
Out[1]=
 
Import taxon names and sequence data as pairs:
In[1]:=
Click for copyable input
Out[1]=