I just wrote some quick Python to generate BEAST2 XML files, either from the command line or for use in your own Python code. See
https://github.com/acorg/beast2-xmlIt's currently very simplistic - there are many things that could be added. I'm not trying to replicate the whole of BEAUTi in Python, but am aiming to make it easy to programmatically (from the shell or from Python) generate BEAST2 config files without needing to use a GUI tool. The code currently has four simple templates to work from (based on clock model) if you don't provide one, all of which come straight from BEAUTi. It can make simple modifications to these. One workflow I imagine is that you set up a base template using BEAUTi, then you pass that to my code along with instructions for the modifications you want.
E.g., suppose you have a BEAST2 XML file (template.xml) you made with BEAUTi. You could write a (bash) shell loop like this:
$ for chainLength in 10000000 20000000 30000000
do
for age in 10 20 30
do
for FASTA in file1 file2
do
beast2xml.py --templateFile template.xml --chainLength \
$chainLength --age id1=$age --logFileBasename \
${chainLength}-${age}-${FASTA} \
< $FASTA.fasta > config.xml
beast-2 config.xml
rm config.xml
done
done
done
Or you can just use a default template, e.g., --clockModel relaxed-exponential.
Feedback welcome. I'd like to improve this (or, better, for you to improve it :-)), while hopefully keeping the code relatively simple.
Terry