emmanuelparadis / ape

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

Tree with a single tip but several nodes is not parsed correctly. #124

Closed kingaa closed 1 month ago

kingaa commented 1 month ago

The following examples with a single tip but several nodes seem to give incorrect results. . This may be a similar issue to #104, but the fix of that issue did not resolve this one.

library(ape)
packageVersion("ape")

"((:1):2):3;" |>
  read.tree(text=_) -> ttt
ttt$edge

"(((:1):2):3):4;" |>
  read.tree(text=_) -> ttt
ttt$edge

"((((:1):2):3):4):5;" |>
  read.tree(text=_) -> ttt
ttt$edge

Running the above, I get

> library(ape)
+ packageVersion("ape")
> [1] ‘5.8.0.1’
> "((:1):2):3;" |>
+   read.tree(text=_) -> ttt
+ ttt$edge
     [,1] [,2]
[1,]    2    3
[2,]    3    1
> "(((:1):2):3):4;" |>
+   read.tree(text=_) -> ttt
+ ttt$edge
     [,1] [,2]
[1,]    2    4
[2,]    3    4
[3,]    3    1
> "((((:1):2):3):4):5;" |>
+   read.tree(text=_) -> ttt
+ ttt$edge
     [,1] [,2]
[1,]    2    4
[2,]    3    5
[3,]    3    5
[4,]    4    1

So the first (3-node) tree is parsed correctly, but the second and third are parsed incorrectly.

emmanuelparadis commented 1 month ago

Actually, all trees are parsed incorrectly: the root edge is not correctly decoded. This is fixed (both bugs) and pushed here (under v. 5.8-0.2). Thanks for the report. Emmanuel

kingaa commented 1 month ago

Brilliant! That seems to have resolved the issue! Thanks so much @emmanuelparadis !