]> git.donarmstrong.com Git - ape.git/blobdiff - R/read.nexus.R
some bug fixes
[ape.git] / R / read.nexus.R
index 3edcd3f5903b610f42edce93884ad2665cb640a0..8c9abc24002e57a27d36e064e92d5317d6f91fc5 100644 (file)
@@ -1,4 +1,4 @@
-## read.nexus.R (2009-04-01)
+## read.nexus.R (2009-10-27)
 
 ##   Read Tree File in Nexus Format
 
@@ -224,7 +224,16 @@ read.nexus <- function(file, tree.names = NULL)
         }
     } else {
         if (!is.null(tree.names)) names(trees) <- tree.names
-        if (translation) attr(trees, "TipLabel") <- TRANS[, 2]
+        if (translation) {
+            if (length(colon) == Ntree) # .treeBuildWithTokens() was used
+                attr(trees, "TipLabel") <- TRANS[, 2]
+            else { # reassign the tip labels then compress
+                for (i in 1:Ntree)
+                    trees[[i]]$tip.label <-
+                        TRANS[, 2][as.numeric(trees[[i]]$tip.label)]
+                trees <- .compressTipLabel(trees)
+            }
+        }
         class(trees) <- "multiPhylo"
     }
     if (length(grep("[\\/]", file)) == 1)