Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newick parsing: handle negative edge lengths, comments #177

Merged
merged 2 commits into from
Jun 17, 2022
Merged

Conversation

cecileane
Copy link
Member

@cecileane cecileane commented Jun 13, 2022

  • negative edge lengths: fixes readTopology with negative edge lengths #176 by setting these lengths (and gamma values) to 0 and sending a log message of :error level
  • allows for (and ignore) nexus-style comments within the extended newick, such as written by other software to add information about population size, posterior probability, mapping of a tip name to a population etc.

@codecov
Copy link

codecov bot commented Jun 13, 2022

Codecov Report

Merging #177 (6a1fb88) into master (1f78b2a) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #177      +/-   ##
==========================================
+ Coverage   85.88%   85.93%   +0.05%     
==========================================
  Files          29       29              
  Lines       11827    11842      +15     
==========================================
+ Hits        10158    10177      +19     
+ Misses       1669     1665       -4     
Impacted Files Coverage Δ
src/readwrite.jl 81.26% <100.00%> (+1.68%) ⬆️
src/phyLiNCoptimization.jl 94.16% <0.00%> (-0.82%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f78b2a...6a1fb88. Read the comment docs.

@cecileane cecileane requested a review from crsl4 June 13, 2022 02:55
@cecileane
Copy link
Member Author

@crsl4 @bstkj @fogg-uw : all the tests pass so I'm ready to merge this PR. But network parsing is quite fundamental, so I'd be happy to give this some time, for you or others to review and perhaps test more cases if you have the leisure to do so (!)

The examples from #176 now give the following with this PR:

julia> net = readTopology("((A:1,B:1):-1,C:2);");
┌ Error: expecting non-negative value but read '-', left parenthesis 2. will set to 0.
└ @ PhyloNetworks ~/.julia/dev/PhyloNetworks/src/readwrite.jl:303

julia> net
HybridNetwork, Rooted Network
4 edges
5 nodes: 3 tips, 0 hybrid nodes, 2 internal tree nodes.
tip labels: A, B, C
((A:1.0,B:1.0):0.0,C:2.0);


julia> net = readTopology("((A:1,B:-1):1,C:2);");
┌ Error: expecting non-negative value but read '-', left parenthesis 2. will set to 0.
└ @ PhyloNetworks ~/.julia/dev/PhyloNetworks/src/readwrite.jl:303

julia> writeTopology(net)
"((A:1.0,B:0.0):1.0,C:2.0);"

and here is an example with nexus-style comments:

julia> net = readTopology("((A:1,B_[&Theta=0.1]:1)[&length=9.47][&prob=0.9]:0.4,C:2);");

julia> writeTopology(net)
"((A:1.0,B_:1.0):0.4,C:2.0);"

@cecileane cecileane merged commit 551ea79 into master Jun 17, 2022
@cecileane cecileane deleted the parsenewick branch June 17, 2022 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

readTopology with negative edge lengths
1 participant