ArtPoon / kamphir

Phylogenetic inference using a tree-shape kernel in an Approximate Bayesian Computation framework
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

crash in Rcolgem, no trees #26

Closed ArtPoon closed 9 years ago

ArtPoon commented 9 years ago
Error in FUN(X[[1L]], ...) : object "phy" has no trees
Traceback (most recent call last):
  File "kamphir.py", line 605, in <module>
    decay=args.toldecay)
  File "kamphir.py", line 424, in abc_mcmc
    next_score = self.evaluate()  # returns None if simulations fail
  File "kamphir.py", line 353, in evaluate
    trees = self.simulate2()
  File "kamphir.py", line 246, in simulate2
    newicks = self.simfunc(self.proposed, self.tip_heights)
  File "/Users/art/git/kamphir/rcolgem.py", line 274, in simulate_DiffRisk_trees
    retval = robjects.r("lapply(trees, write.tree)")
  File "/Library/Python/2.7/site-packages/rpy2-2.5.6-py2.7-macosx-10.9-intel.egg/rpy2/robjects/__init__.py", line 269, in __call__
    res = self.eval(p)
  File "/Library/Python/2.7/site-packages/rpy2-2.5.6-py2.7-macosx-10.9-intel.egg/rpy2/robjects/functions.py", line 170, in __call__
    return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/rpy2-2.5.6-py2.7-macosx-10.9-intel.egg/rpy2/robjects/functions.py", line 100, in __call__
    res = super(Function, self).__call__(*new_args, **new_kwargs)
rpy2.rinterface.RRuntimeError: Error in FUN(X[[1L]], ...) : object "phy" has no trees
ArtPoon commented 9 years ago

Wrapped the offending bit of R code in a try..except at the Python level. This not ideal because a warning gets thrown at the system level but the chain is continuing to run, so it's a decent patch for now. I think the ideal solution would be to exclude the offending trees in the List object and return the others, but my first attempts at this haven't worked.