emmanuelparadis / ape

analysis of phylogenetics and evolution
http://ape-package.ird.fr/
GNU General Public License v2.0
52 stars 11 forks source link

write.tree not using tree.names #101

Closed IanGBrennan closed 10 months ago

IanGBrennan commented 10 months ago

Hello, thanks for the development and maintenance of such an incredible resource.

the tree.names = TRUE argument of write.tree doesn't seem to write the tree names to file. e.g.

trees <- NULL
trees[[1]] <- read.tree(text="(A,(B,C));")
trees[[2]] <- read.tree(text="(C,(B,A));")
class(trees) <- "multiPhylo"
names(trees) <- c("Opt1", "Opt2")
write.tree(trees, file="TEST.trees", tree.names = T)

I think it's that .write.tree2 doesn't use the tree.prefix argument when it pastes the newick string in the last line, e.g. the last line should read paste0(tree.prefix, " ", NEWICK[root], ";") instead.

Thanks for any help.

emmanuelparadis commented 10 months ago

Hello Ian, thanks for the appreciation!

Your diagnostic is correct: this bug was introduced in ape 5.7. I've fixed it and pushed a new version here.

It seems there used to be no space between the tree name (stored in tree.prefix) and the Newick string, so I omitted the , " " from your suggestion.

Cheers,

IanGBrennan commented 10 months ago

Fantastic. Thanks for fixing so quickly.