From d04b9fc742bdc429064eda478502f23885465ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Vigil-V=C3=A1squez?= Date: Thu, 16 Jan 2025 13:43:45 +0100 Subject: [PATCH 1/3] feat: handle plus sign in scientific notation floats --- src/readwrite.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/readwrite.jl b/src/readwrite.jl index 61043054..89beb5e3 100644 --- a/src/readwrite.jl +++ b/src/readwrite.jl @@ -113,19 +113,19 @@ end # aux function to read floats like length or gamma values, to be read after a colon function readnewick_float(s::IO, c::Char) - if !(isdigit(c) || c in ['.','e','-','E']) + if !(isdigit(c) || c in ['.','e','-','E', '+']) a = read(s, String); error("Expected float digit after ':' but found $(c). remaining is $(a)."); end num = "" - while isdigit(c) || c in ['.','e','-', 'E'] + while isdigit(c) || c in ['.','e','-', 'E', '+'] d = read(s, Char) # reads c and advances IO num = string(num,d); c = peekskip(s); end f = 0.0 try - f = parse(Float64, num) + f = parse(Float64, replace(num, '+' => "")) catch error("problem with number read $(num), not a float number") end From d6dc612f428949aa15d7fc6b834af389b9263c17 Mon Sep 17 00:00:00 2001 From: Cecile Ane Date: Mon, 10 Mar 2025 16:16:27 -0500 Subject: [PATCH 2/3] raw html in docs: fixed paths to images --- docs/src/man/introduction.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/man/introduction.md b/docs/src/man/introduction.md index 1877d70a..d4cec380 100644 --- a/docs/src/man/introduction.md +++ b/docs/src/man/introduction.md @@ -119,7 +119,7 @@ gene flow/hybridization or gene tree estimation error, and can be hard to interpret biologically. ```@raw html -implicit split network +implicit split network ``` In PhyloNetworks, we consider **explicit** phylogenetic networks exclusively. @@ -130,14 +130,14 @@ In parenthetical format, internal nodes can have a name, like node `C` below, in a tree written as `(A,B)C` in newick format: ```@raw html -internal tree node C +internal tree node C ``` To represent networks in parenthetical format, the extended newick format splits each hybrid node into two nodes with the same name: ```@raw html -a hybrid node is split into 2 nodes with the same name, to represent a network as a tree +a hybrid node is split into 2 nodes with the same name, to represent a network as a tree ``` By convention, the hybrid tag is `# + H,LGT,R + number`, and the minor @@ -174,4 +174,4 @@ the edge was a tree edge: setgamma!(net.edge[4], 0.7) # should return this: # ERROR: cannot change gamma in a tree edge -``` \ No newline at end of file +``` From a06e6ff5ad56ae759110e40f8048c3292744a6ec Mon Sep 17 00:00:00 2001 From: Cecile Ane Date: Mon, 10 Mar 2025 16:49:15 -0500 Subject: [PATCH 3/3] let parse(Float,...) handle the + sign. Test added. --- src/readwrite.jl | 2 +- test/test_relaxed_reading.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/readwrite.jl b/src/readwrite.jl index 89beb5e3..c29559d4 100644 --- a/src/readwrite.jl +++ b/src/readwrite.jl @@ -125,7 +125,7 @@ function readnewick_float(s::IO, c::Char) end f = 0.0 try - f = parse(Float64, replace(num, '+' => "")) + f = parse(Float64, num) catch error("problem with number read $(num), not a float number") end diff --git a/test/test_relaxed_reading.jl b/test/test_relaxed_reading.jl index 686847a7..a01f813e 100644 --- a/test/test_relaxed_reading.jl +++ b/test/test_relaxed_reading.jl @@ -35,6 +35,11 @@ global net @test_throws Exception readnewick("(E,((B)#H1") # doesn't end with ; @test_throws Exception readnewick(IOBuffer("E;")) # Expected beginning of tree with ( end +@testset "edge parameters" begin + net = readnewick("(A:2e-03,((B:1.2e1,#H1:1e+1):2.2E-02,(D:1.1E+2)#H1:4.4E+2::5.5E-10));") + @test [e.length for e in net.edge] == [0.002,12,10,0.022,110,440,-1] + @test [e.gamma for e in net.edge if e.hybrid] == [0.99999999945, 5.5e-10] +end @testset "ismajor & gamma consistency, and miscellaneous" begin net = readnewick("((((B)#H1)#H2,((D,C,#H2:::0.8),(#H1,A))));"); @test writenewick(net, round=true, digits=8) == "(#H2:::0.2,((D,C,((B)#H1)#H2:::0.8),(#H1,A)));"