Add the following two highlighted lines to main.cpp (after createTestTree()
):
#include <iostream>
#include "node.hpp"
#include "tree.hpp"
#include "tree_manip.hpp"
using namespace strom;
const double Node::_smallest_edge_length = 1.0e-12;
int main(int argc, const char * argv[]) {
std::cout << "Starting..." << std::endl;
TreeManip tm;
tm.createTestTree();
<span style="color:#0000ff"><strong>std::cout << tm.makeNewick(3) << std::endl;</strong></span>
<span style="color:#0000ff"><strong>std::cout << tm.makeNewick(3, true) << std::endl;</strong></span>
std::cout << "\nFinished!" << std::endl;
return 0;
}
The first of these lines will generate a newick tree description using numbers (because the default value of the makeNewick
parameter use_names
is false
), while the second one will generate a newick descriptions in which the names stored in each tip node are used.
Build strom using the usual meson install
command from the build
directory:
cd ~/Documents/strom/build
meson install
This time things will not go smoothly, however. You should see errors to the effect that boost/format.hpp does not exist. The problem is that we’ve used a feature from a header format.hpp in the Boost C++ library but have not yet told meson where this header file can be found. In fact, we have not yet even installed the Boost C++ library, so let’s do that now.
In your browser, go to the Boost C++ home page, find the latest release, and navigate to the Downloads page. Copy the link address for the gzipped tar file for the latest version and download it into your home directory as follows:
cd
curl -LO https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz
Here, the -L switch tells curl to follow the path indicated if the original file has moved and redirection information has been provided. The -O switch tells curl to save the file under the name specified in the last part of the URL.
Create the directory ~/Documents/libraries, then use the tar command to uncompress and untar the boost_1_71_0.tar.gz into the libraries directory as follows:
cd ~/Documents
mkdir libraries
cd libraries
tar zxvf ~/boost_1_71_0.tar.gz
We now need to modify the meson.build file to tell meson where to find the boost headers:
project('strom', 'cpp',
default_options : ['cpp_std=c++11','cpp_link_args=-static','prefix=/home/paul/Documents/strom/distr'],
version : '1.0')
incl_boost = include_directories('/home/paul/Documents/libraries/boost_1_71_0')
executable('strom', 'main.cpp', install: true, install_dir: '.', include_directories: incl_boost)
I’ve added an include_directories
command pointing to the boost install directory and stored this directory as the meson variable incl_boost
. You should of course use the correct absolute path to your boost installation; unless your user name is paul
, the include_directories
command will not work as written above! Note that I’ve also appended , include_directories: incl_boost
to the end of the executable
command.
Go ahead and compile strom again. This time it should compile and install cleanly. You should see the following additional lines appear in the output when the program is run:
((1:0.100,2:0.100):0.100,3:0.200)
((first_leaf:0.100,second_leaf:0.100):0.100,third_leaf:0.200)
Note that 3 decimal places are used in outputting edge lengths because you supplied 3 as an argument to the makeNewick
function.