Question: How To Convert A Fasta Or Alignment File To Nexus (.Nex) File That Is To Be Used In The Beast Program
gravatar for triinlakspere
7.4 years ago by
triinlakspere20 wrote:

Dear fellow scientists!

I'm new in the field and need some help with a small problem.

I have an .aln and .fas files of aligned nucleotide samples.

For phylogenetical analysis, I'm using BEAST program which requires the input file to be in NEXUS format (especially .nex not .nxs).

I've tried many options but just keep getting errors.

Do you know how can I properly convert FASTA or alignment file to NEXUS file?


ADD COMMENTlink modified 6.5 years ago by Irene0 • written 7.4 years ago by triinlakspere20
gravatar for csmall
6.8 years ago by
United States
csmall60 wrote:

You might want to try using seqmagick. It's a command line utility inspired by imagemagick that provides a number of very handy utilities for modifying sequence files. You can accomplish the desired conversion using

seqmagick convert --output-format nexus --alphabet dna input.fasta output.nex
ADD COMMENTlink written 6.8 years ago by csmall60

this looks really cool, never heard of it before, needs to be a default install on every bio system

ADD REPLYlink modified 13 months ago by _r_am32k • written 6.8 years ago by Istvan Albert ♦♦ 86k
gravatar for Hamish
7.4 years ago by
Hamish3.2k wrote:

I assume that by '.aln' you mean Clustal alignment format and that your '.fas' is a fasta sequence format alignment. In which case the following options suggest themselves for reformatting the alignment:

However your comments suggest that you need to add additional information, beyond just the sequence alignment, to the NEXUS file to get something that will work with BEAUti and thus generate the XML file to input to BEAST. For an overview of some of the information that can be included in a NEXUS file see:

The example NEXUS files provided in the BEAST distribution may provide suggestions as to the missing information.

ADD COMMENTlink written 7.4 years ago by Hamish3.2k
gravatar for Prakki Rama
6.8 years ago by
Prakki Rama2.4k
Prakki Rama2.4k wrote:

another online sequence conversion tool.

ADD COMMENTlink modified 13 months ago by _r_am32k • written 6.8 years ago by Prakki Rama2.4k
gravatar for Irene
6.5 years ago by
Irene0 wrote:

You can now import FASTA files to BEAST 2, but I still needed to use a NEXUS file because I wanted to link the trees of different partitions and this isn't possible if you import the partitions as separated FASTA files, only if they are partitions within a NEXUS file. I recommend Sequence Matrix ( to solve this problems. It's written in Java, very easy to use, and if you have different FASTA files with different sequences from the same samples you can import all of them and if the names (>name) are the same, then you can export it as a NEXUS file that records the partitions, so if you use this file as input for Beauti the partitions are automatically recognised and you can link their trees. Of course if you import a single FASTA file and export it as NEXUS it will be acting as a converter. 

ADD COMMENTlink written 6.5 years ago by Irene0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1867 users visited in the last hour