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.
January 19th, 2009 at 8:44 pm
[...] 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 [...]
January 14th, 2011 at 9:25 pm
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.
January 15th, 2011 at 5:55 pm
There’s a BNF on the wikipedia page: http://en.wikipedia.org/wiki/Newick_format
April 23rd, 2011 at 3:59 pm
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!
April 25th, 2011 at 4:29 am
No problem, you are welcome (as long as you don’t blame me if there is problems with it) :)