[Phylobase-commits] r824 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 9 21:18:44 CET 2011


Author: francois
Date: 2011-02-09 21:18:44 +0100 (Wed, 09 Feb 2011)
New Revision: 824

Modified:
   pkg/R/treewalk.R
Log:
little tweak in treewalk function

Modified: pkg/R/treewalk.R
===================================================================
--- pkg/R/treewalk.R	2010-12-31 09:05:11 UTC (rev 823)
+++ pkg/R/treewalk.R	2011-02-09 20:18:44 UTC (rev 824)
@@ -229,14 +229,18 @@
 # shortestPath
 ###############
 shortestPath <- function(phy, node1, node2){
-    ## if(!require(phylobase)) stop("phylobase package is not installed")
+  ## if(!require(phylobase)) stop("phylobase package is not installed")
 
-    ## conversion from phylo, phylo4 and phylo4d
+  ## conversion from phylo, phylo4 and phylo4d
+  if (class(phy) == "phylo4d") {
+    x <- extractTree(phy)
+  }
+  else if (class(phy) != "phylo4"){
     x <- as(phy, "phylo4")
-    ## FIXME: use extractTree if coming from phylo4d
+  }
 
     ## some checks
-    if (is.character(checkval <- checkPhylo4(x))) stop(checkval)
+    ## if (is.character(checkval <- checkPhylo4(x))) stop(checkval) # no need
     t1 <- getNode(x, node1)
     t2 <- getNode(x, node2)
     if(any(is.na(c(t1,t2)))) stop("wrong node specified")



More information about the Phylobase-commits mailing list