5.2 Test creating Newick strings

(Win version)

< 5.1 | 5.2 | 6.0 >

Add the following two highlighted lines to main.cpp (after createTestTree()):

#include &lt;iostream&gt; 
#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 &lt;&lt; "Starting..." &lt;&lt; std::endl;
    TreeManip tm;
    tm.createTestTree();
    <span style="color:#0000ff"><strong>std::cout &lt;&lt; tm.makeNewick(3) &lt;&lt; std::endl;</strong></span>
    <span style="color:#0000ff"><strong>std::cout &lt;&lt; tm.makeNewick(3, true) &lt;&lt; std::endl;</strong></span>
    std::cout &lt;&lt; "\nFinished!" &lt;&lt; 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.

Installing the Boost header files

In your browser, go to the Boost C++ home page, find the latest release (1.71.0 at this writing), and navigate to the Downloads page. Download the file boost_1_71_0.zip and extract into the directory of your choice. I will assume that you extracted it at ~/Documents/libraries, which I will hereafter refer to as the libraries directory). You should now have a directory ~/Documents/libraries/boost_1_71_0, which I will hereafter refer to as BOOST_ROOT.

Important notes about zip files in Windows

Windows can fool you into thinking you have a folder when in reality the apparent folder is still in form of a zip file. If what looks like the boost_1_71_0 folder has a zipper on the icon, beware! The zipper means it is still a zip file. VSC19 will only be able to use files if they have been extracted from the boost_1_71_0.zip file.

Windows is notoriously slow at extracting large zip files, so I recommend downloading the 7-zip program to do the unzipping for you. Once installed, you can right-click the zip file and choose Extract here from the 7-zip menu to unpack the boost libraries. It will still take awhile (because Boost is huge) but it will unpack orders of magnitude faster than using the native Windows unzipper.

Finally, deleted the boost_1_71_0.zip file (the one with the zipper on the icon) after you extract it to avoid future confusion.

Add Boost to header search path

Now we need to tell VSC19 about the Boost library so that we can use Boost header files and compiled libraries in our project.

Right-click the strom project (note: click the project, not the solution) in the Solution Explorer pane of VSC19 and choose Properties from the popup menu. Expand VC++ Directories, then click on Include Directories, then click the down-pointing triangle, then click <Edit…> and add BOOST_ROOT, which, you remember from the paragraph above, is ~/Documents/libraries/boost_1_71_0, where the ~ is a stand-in for your home directory. The easiest way to get this right is to use the button that allows you to add a new line, then click the elipses (...) button on the right end of that line, then choose the BOOST_ROOT directory using the file chooser. When I finished this process, the line read:

C:\Users\Paul Lewis\Documents\libraries\boost_1_71_0

Compile and run

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.

< 5.1 | 5.2 | 6.0 >