ArtPoon/kamphir

NewickIO bug

Opened this issue · 3 comments

Traceback (most recent call last):
  File "diffrisk.py", line 79, in <module>

  File "/Users/art/git/kamphir/kamphir.py", line 282, in abc_mcmc
    next_score = self.evaluate()
  File "/Users/art/git/kamphir/kamphir.py", line 233, in evaluate
    async_results = [apply_async(pool, self.compute, args=(tree,)) for tree in trees]
  File "/Library/Python/2.7/site-packages/Bio/Phylo/_io.py", line 53, in parse
    for tree in getattr(supported_formats[format], 'parse')(fp, **kwargs):
  File "/Library/Python/2.7/site-packages/Bio/Phylo/NewickIO.py", line 118, in parse
    yield self._parse_tree(buf)
  File "/Library/Python/2.7/site-packages/Bio/Phylo/NewickIO.py", line 171, in _parse_tree
    raise NewickError('Parenthesis mismatch.')
Bio.Phylo.NewickIO.NewickError: Parenthesis mismatch.

from NewickIO.py:

            elif token == ')':
                # done adding children for this parent clade
                parent = self.process_clade(current_clade)
                if not parent:
                    raise NewickError('Parenthesis mismatch.')

So script is encountering a tree string with an unmatched closing parenthesis.

This bug has a very low rate of occurrence. I am going to catch this exception in kamphir.py, simulate() by "manually" iterating over the file of Newick strings and passing the rare case where the string is mangled. The rest of the parsed trees will be returned as a List object. Eventually it would be nice to chase this one, but for now I'm closing with commit.

Captured a couple of trees that raised this exception, saved as crash.tree and crash2.tree.