From: paradis Date: Mon, 24 Nov 2008 08:30:45 +0000 (+0000) Subject: fix bug in read.nexus() X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=commitdiff_plain;h=de88c4801a78a3d1a8376c19be8c852727eeaf09 fix bug in read.nexus() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@55 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/ChangeLog b/ChangeLog index 1a6a7ab..8891e33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ BUG FIXES o chronopl() did not work with CV = TRUE. + o read.nexus() did not work correctly in some situations (trees on + multiple lines with different numbers of lines and/or with + comments inserted within the trees). + CHANGES IN APE VERSION 2.2-2 diff --git a/DESCRIPTION b/DESCRIPTION index c2fab9e..74b1a1d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.2-3 -Date: 2008-11-04 +Date: 2008-11-24 Title: Analyses of Phylogenetics and Evolution Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, diff --git a/R/read.nexus.R b/R/read.nexus.R index cbf0f20..01aec64 100644 --- a/R/read.nexus.R +++ b/R/read.nexus.R @@ -1,4 +1,4 @@ -## read.nexus.R (2008-09-17) +## read.nexus.R (2008-11-24) ## Read Tree File in Nexus Format @@ -153,6 +153,8 @@ read.nexus <- function(file, tree.names = NULL) tree <- X[start:end] rm(X) tree <- gsub("^.*= *", "", tree) + ## check whether there are empty lines from the above manips: + tree <- tree[tree == ""] semico <- grep(";", tree) Ntree <- length(semico) ## are some trees on several lines? @@ -161,8 +163,13 @@ read.nexus <- function(file, tree.names = NULL) STRING <- character(Ntree) s <- c(1, semico[-Ntree] + 1) j <- mapply(":", s, semico) - for (i in 1:Ntree) - STRING[i] <- paste(tree[j[, i]], collapse = "") + if (is.list(j)) { + for (i in 1:Ntree) + STRING[i] <- paste(tree[j[[i]]], collapse = "") + } else { + for (i in 1:Ntree) + STRING[i] <- paste(tree[j[, i]], collapse = "") + } } else STRING <- tree } rm(tree) diff --git a/Thanks b/Thanks index 0bac636..adf40fd 100644 --- a/Thanks +++ b/Thanks @@ -4,9 +4,10 @@ APE at one stage or another. Many users gave important feed-back with their encouragements, comments, or bug reports: thanks to all of you! -Significant bug fixes were provided by James Bullard, Éric Durand, -Olivier François, Bret Larget, Elizabeth Purdom, Klaus Schliep, -Li-San Wang, and Yan Wong. Contact me if I forgot someone. +Significant bug fixes were provided by Cécile Ané, James Bullard, +Éric Durand, Olivier François, Bret Larget, Elizabeth Purdom, +Klaus Schliep, Li-San Wang, and Yan Wong. Contact me if I forgot +someone. Kurt Hornik, of the R Core Team, helped in several occasions to fix some problems and bugs.