X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fwrite.nexus.R;h=2a3c32ada3ce1a5102abf6d0c1492a25bcb6fc90;hb=b0548f80b3ac1d2035ddc360d3366eab4f08d247;hp=14f77341c498bfcd4a2f3bfbadffd905bdc3de2d;hpb=bd53d983d5daf867bc50b00ace48d017506599ef;p=ape.git diff --git a/R/write.nexus.R b/R/write.nexus.R index 14f7734..2a3c32a 100644 --- a/R/write.nexus.R +++ b/R/write.nexus.R @@ -1,8 +1,8 @@ -## write.nexus.R (2009-10-27) +## write.nexus.R (2011-02-26) ## Write Tree File in Nexus Format -## Copyright 2003-2009 Emmanuel Paradis +## Copyright 2003-2011x Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -76,13 +76,21 @@ the original data won't be written with the tree.")) } } else { for (i in 1:ntree) - obj[[i]]$tip.label <- checkLabel(obj[[i]]$tip.label) + obj[[i]]$tip.label <- checkLabel(obj[[i]]$tip.label) } + + title <- names(obj) + if (is.null(title)) + title <- rep("UNTITLED", ntree) + else { + if (any(s <- title == "")) title[s] <- "UNTITLED" + } + for (i in 1:ntree) { if (class(obj[[i]]) != "phylo") next if (is.rooted(obj[[i]])) - cat("\tTREE * UNTITLED = [&R] ", file = file, append = TRUE) - else cat("\tTREE * UNTITLED = [&U] ", file = file, append = TRUE) + cat("\tTREE *,", title[i], "= [&R] ", file = file, append = TRUE) + else cat("\tTREE *", title[i], "= [&U] ", file = file, append = TRUE) cat(write.tree(obj[[i]], file = ""), "\n", sep = "", file = file, append = TRUE) }