10+ ways to generate BEAST XML

By Remco Bouckaert

Every self respecting BEAST developer has encountered the problem of wanting to create a lot of XML files, for example for a simulation study, and using BEAUti just takes too long. It seems there are as many ways to generate XML as there are developers. Here is a non-exhaustive list in no particular order of things people have done in the past to generate XML.

Roll your own Java

There are a few classes in BEAST that can be useful for generating XML, in particular beast.app.seqgen.SequenceSimulator to simulate sequences on a tree, beast.app.seqgen.MergeDataWith to merge the generated alignment with an XML file, and beast.util.XMLProducer.


You can use XML to generate new XML in BEAST, as explained here: simulation studies with BEAST 2. BEAST v2.5 (available soon) will have a command line interface to replace variables in the XML, allowing say

<run chainLength="$(chainLength)" ...

to be replaced by a number from the command line when running

beast -D "chainLength=1000000" file.xml

so it will be interpreted as

<run chainLength="1000000" ....


BEASTGen by Andre Rambaut is part of BEAST 1, but is a generic XML producer from templates, so it can produce BEAST 2 XML as well. It has functionality to recognise alignment files, so you can refer to NEXUS and FASTA files to include in the XML.


BEASTmasteR by Nick Matzke is based on R. The purpose of BEASTmasteR is to convert NEXUS data file(s) (DNA, amino acids, discrete morphological characters, and/or continuous traits), plus an Excel settings file, into Beast2 XML format.


MiXeL by Joseph Heled is based on python and uses XML template files that can be mixed and matched.


BEASTLing by Luke Mauritz et al aim specifically at generating BEAST XML for linguistic analyses.


babette by Richelle Bilderbeek and Rampal Etienne stands for "BEAUti 2, BEAST2 and Tracer for R" aims to aid in the workflow or performing an analysis through scripting in R.


BEAST2XML by Terry Jones is a Python class and command-line script to generate BEAST 2 XML files.


BEASTShell is based on Bean Shell and integrated with BEAST. This post explains how to use it to generate XML.


Beasy is a Java based attempt by myself to use the power of BEAUti templates. Unlike most of the above approaches, when new packages get added no custom scripts are required to be able to use the new packages when there is a BEAUti template. It is still in development...


If you know any other ways to generate XML, please let me know.


Matzke, Nicholas J. (2015). "BEASTmasteR: R tools for automated conversion of NEXUS data to BEAST2 XML format, for fossil tip-dating and other uses."

Richel J.C. Bilderbeek, Rampal S. Etienne. babette: BEAUti 2, BEAST2 and Tracer for R doi: https://doi.org/10.1101/271866

Maurits, Luke, Robert Forkel, Gereon A. Kaiping, and Quentin D. Atkinson. "BEASTling: A software tool for linguistic phylogenetics using BEAST 2." PloS one 12, no. 8 (2017): e0180908.