Newick C++ parser in Boost.Spirit

Here’s the Newick parser for C++ I mentioned in a previous post.  It is written in Boost.Spirit, so it is a recursive decend parser.  This might give you problems with the stack if you are parsing really deep trees, but for moderately sized trees (a few thousands of taxa) it shouldn’t be a problem.

It is code I pulled out of a tool for coalescence trees, so it only handles rooted binary trees.  To make it a little more useful I’ll add code for re-rooting the tree.  I have that code already, but in a different tool that only works on the tree topology, so I need to handle the branch lengths before I can add it here.

Let me know what you think.

Tags: , ,

5 Responses to “Newick C++ parser in Boost.Spirit”

  1. Mailund on the Internet » Blog Archive » Yet another Newick parser Says:

    [...] little while back, I wrote a Newick parser for C++ using Boost.Spirit, and last month I needed to update my Python parser for Newick, so I tried out the Toy Parser [...]

  2. Arlin Stoltzfus Says:

    I’m trying to find a BNF description of Newick. This is for a report on best practices for publishing phylogenetic trees (see http://wiki.tdwg.org/twiki/bin/view/Phylogenetics/LinkingTrees2010). I will acknowledge any contribution you make in the report.

  3. Thomas Mailund Says:

    There’s a BNF on the wikipedia page: http://en.wikipedia.org/wiki/Newick_format

  4. Emmanuel Teisaire Says:

    Hi, I’d like to use your parser for a non comercial phylogenetic project. It’s for a foundation called FUDEPAN. It is just what we need so it’ll save us some time. Thanks a lot!

  5. Thomas Mailund Says:

    No problem, you are welcome (as long as you don’t blame me if there is problems with it) :)

Leave a Reply