This code converts Newick trees/networks into a format accepted by the phylogenetic simulation software ms.
msConverter is a C++ program made to convert trees and networks in Newick format to the format accepted by ms.
# Read by file and output to a file
./ms-converter newick-trees.file --output=ms-args.file
# Read by Newick and output to the command line
# This also shows some WARNINGS that ms-converter throws which can be silenced with --quiet
./ms-converter --newick="((1:0.1,((2:0.2,(3:0.3,(4:0.4)Y#H1:3.0)g:0.6)e:0.7,(((Y#H1:0.8,5:0.9)h:1.0,6:1.1)f:1.2)X#H2:1.3)c:1.4)a:1.5,((X#H2:0.4,7:1.7)d:1.8,8:1.9)b:2.0)r;"The program can also directly run ms for you (unless you're using Windows, sorry):
## If `ms` is in your system path, all you need to do is add --run
# Read Newick strings from the file newicks.file (new line deliminated), simulate under each Newick 50 times, and output all of the simulated trees to sim.trees
./ms-converter newicks.file --run --n 50 --output=sim.trees
# Do the same as above, but output the raw `ms` output to the terminal, not just the simulated trees
./ms-converter newicks.file --run -n 50 --dirty
## If `ms` is NOT in your system path, you have to tell the program where it is
# Do as above, but specify the location of `ms` (NOTE: this is the FOLDER CONTAINING ms, not ms itself)
./ms-converter newicks.file --run -n 50 --dirty --ms_path=/opt/msdir/- In the Newick format provided to
ms-converter, gamma must be specified on both nodes involved in a hybrid event, and all unspecified branch lengths are assumed to be 0. msis designed to work with extant taxa, so only ultrametric trees and networks make sense within it. So, all input trees/networks are made ultrametric before translated to themsformat.
Requirements:
- CMake
- Boost C++ Libraries (v1.60.0 or greater) with at least the
program_optionslibrary compiled. Installation instructions:- MacOSX, homebrew:
brew install boost, MacPorts:port install boost - Windows
- Ubuntu:
apt-get install libboost-all-dev
- MacOSX, homebrew:
- C++ compiler and standard libraries (make sure these are up-to-date if compilation fails)
Optional:
- ms (not msHOT)
Once these requirements are fulfilled, compile via the following commands:
git clone https://github.com/NathanKolbow/msConverter.git
mkdir msConverter/build
cd msConverter/build
cmake ..
cmake --build .
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseThe executable ms-converter will then be located in build/ms-converter (build/Release/ms-converter.exe on Windows)