5.2 Test creating Newick strings

(Mac 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.tar.gz or boost_1_71_0.zip and unpack in the directory of your choice. I will assume that you unpacked it at ~/Documents/libraries so that you now have a directory ~/Documents/libraries/boost_1_71_0.

Create a custom path (alias) for the Boost library root directory

Choose Xcode > Preferences… from the main menu, then choose the “Locations” tab, then click the “Custom Paths” subtab.

Click the + button and add a new custom path item named BOOST_ROOT with display name BOOST_ROOT. On my computer, I entered the path /Users/plewis/Documents/libraries/boost_1_71_0 (but you should of course modify this for your case).

Click the red button at the top left to close the preferences dialog box.

Add Boost to header search path

Click once on the strom project (with the blue project icon :blueproject:) in the Project Navigator, then select the strom TARGET within the project settings shown in the central pane. You should now see General, Resource Tags, Build Settings, Build Phases, and Build Rules across the top of the central pane.

Click on Build Settings, All (not Basic or Customized), Levels (not Combined), and then type “Header Search Paths” into the Search box to filter out all build settings except the one we are interested in at the moment.

In the “Header Search Paths” row, double-click on the column with the blue project icon :blueproject: (this is the column for the project settings, the other column labeled strom contains target-specific settings).

Click the + button at the bottom left corner and type $(BOOST_ROOT) (this will expand to the custom path you defined earlier).

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 >