From: paradis Date: Tue, 24 Jun 2008 09:51:36 +0000 (+0000) Subject: bug fix in read.nexus() X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9ff298298bf4312d056134fd549157386e986304;p=ape.git bug fix in read.nexus() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@37 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/Changes b/Changes index df065d4..e2ea0af 100644 --- a/Changes +++ b/Changes @@ -15,7 +15,9 @@ BUG FIXES o Several bugs were fixed in mlphylo(). o collapsed.singles() did not propagate the 'Nnode' and - 'node.labels' elements (thanks to Elizabeth Purdom for the fix. + 'node.labels' elements (thanks to Elizabeth Purdom for the fix). + + o read.nexus failed to remove correctly the comments within trees. OTHER CHANGES diff --git a/DESCRIPTION b/DESCRIPTION index 71e4a76..5f5dcf0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.2-1 -Date: 2008-06-19 +Date: 2008-06-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 ff148df..05acfcd 100644 --- a/R/read.nexus.R +++ b/R/read.nexus.R @@ -1,4 +1,4 @@ -## read.nexus.R (2008-02-28) +## read.nexus.R (2008-06-24) ## Read Tree File in Nexus Format @@ -109,7 +109,17 @@ read.nexus <- function(file, tree.names = NULL) w <- LEFT == RIGHT if (any(w)) { # in case all comments use at least 2 lines s <- LEFT[w] - X[s] <- gsub("\\[.*\\]", "", X[s]) + X[s] <- gsub("\\[[^]]*\\]", "", X[s]) + ## The previous regexp was quite tough to find: it makes + ## possible to delete series of comments on the same line: + ## ...[...]xxx[...]... + ## without deleting the "xxx". This regexp is in three parts: + ## \\[ [^]]* \\] + ## where [^]]* means "any character, except "]", repeated zero + ## or more times" (note that the ']' is not escaped here). + ## The previous version was: + ## X[s] <- gsub("\\[.*\\]", "", X[s]) + ## which deleted the "xxx". (EP 2008-06-24) } w <- !w if (any(w)) {