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

readnewick and empty taxon names #222

Closed
colbec opened this issue Dec 23, 2024 · 2 comments
Closed

readnewick and empty taxon names #222

colbec opened this issue Dec 23, 2024 · 2 comments

Comments

@colbec
Copy link

colbec commented Dec 23, 2024

Forgive my unfamiliarity with the detail of the Newick format - when I attempt to read in the string
tree = "((A,B),(,));"
the readnewick() parser chokes on the "(,)" and cannot proceed. I have seen this frequently in example strings.
Does the parser not handle this at this time?

@cecileane
Copy link
Member

No, leaves need to have a label. In your example, there are 2 leaves without labels, as part of this near the end: (,).
The following should work:

julia> tree = "((A,B),(fakelabel1,fakelabel2));" ;

julia> readnewick(tree)
HybridNetwork, Rooted Network
6 edges
7 nodes: 4 tips, 0 hybrid nodes, 3 internal tree nodes.
tip labels: A, B, fakelabel1, fakelabel2
((A,B),(fakelabel1,fakelabel2));

@colbec
Copy link
Author

colbec commented Dec 24, 2024

Thanks, this was helpful. For others in the same situation the following process worked for me to produce a raw string that the parser was happy with. Whether the final result is the tree that the original author intended is another matter. It is a very pedestrian and inefficient process but allows for examination of intermediate steps in case further problems arise.

while occursin("(,)",tree)
    x = randstring('A':'Z',6)
    y = randstring('A':'Z',7)
    tree = replace(tree,"(,)"=>"($x,$y)",count=1)
end
while occursin(",)",tree)
    z = randstring('A':'Z',6)
    tree = replace(tree,",)"=>",$z)",count=1)
end
while occursin("(,",tree)
    z = randstring('A':'Z',6)
    tree = replace(tree,"(,"=>"($z,",count=1)
end
while occursin(",,",tree)
    z = randstring('A':'Z',6)
    tree = replace(tree,",,"=>",$z,",count=1)
end
while occursin("()",tree)
    z = randstring('A':'Z',6)
    tree = replace(tree,"()"=>"($z)",count=1)
end

@colbec colbec closed this as completed Dec 24, 2024
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

No branches or pull requests

2 participants