Skip to content

Change Newick tree parsing to handle numeric names - #360

Closed
bsmith89 wants to merge 1 commit into
biopython:masterfrom
bsmith89:master
Closed

bsmith89 wants to merge 1 commit into
biopython:masterfrom
bsmith89:master

Conversation

@bsmith89

Copy link
Copy Markdown
Contributor

Numeric taxa names in Newick trees are parsed as branch confidence.
For instance a newick file

(((0:0.1,1:0.1)0.99:0.1,2:0.1)0.98:0.0);

would be parsed as a tree with three, unnamed terminal nodes with confidence values of 0, 1, and 2.

I believe this is a bug, since branches to (edit 9/12) terminal nodes shouldn't have confidence values.
I've edited Bio/Phylo/NewickIO.py so that it behaves as I would expect, and written a unit test.

@etal

etal commented Sep 11, 2014

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This reasoning makes sense to me.

However: This would break compatibility between versions as it is. It would be safer to add a flag like allow_integer_names (similar to values_are_confidence and comments_are_confidence) to enable this behavior on new scripts. But if the alternative is basically unusable, then we would want to just fix it.

The current behavior derives from the Bio.Nexus module, so I'd like to hear from the original authors why they chose this behavior. (Is Frank on Github?)

@peterjc

peterjc commented Sep 11, 2014

Copy link
Copy Markdown
Member

Does the problem happen if using the Bio.Nexus parser directly? If so, it makes sense to fix it there rather than in the Bio.Phylo wrapper.

@etal

etal commented Sep 19, 2014

Copy link
Copy Markdown
Contributor

The Bio.Phylo Newick parser is a port rather than a wrapper of the Bio.Nexus.Trees parser; I left this behavior the same under the assumption that the original authors had specific reasons for wanting these options and default behaviors, but we're free to diverge if we have good reasons (I agree with @bsmith89 that this patch is better default behavior).

Bio.Phylo's Nexus parser does call out to Bio.Nexus to parse trees, so if we change the behavior here, we should also change Bio.Nexus.Trees similarly so that Bio.Phylo's "newick" and "nexus" formats behave the same.

@peterjc

peterjc commented Sep 19, 2014

Copy link
Copy Markdown
Member

I don't think Frank is on GitHub - best bring this up on the biopython-dev list for comment?

@cymon

cymon commented Sep 19, 2014

Copy link
Copy Markdown

It looks like a bug to me; it should clearly be parsed as 3 taxa name 0, 1 and 2

@frankkl

frankkl commented Sep 22, 2014

Copy link
Copy Markdown
Contributor

I think (without looking at the code) this is because these values (separated with a column) originally were to be interpreted as branch lengths and confidence values, which is on purpose. Support for labels was added later (was that me, actually...?).

@etal

etal commented Sep 22, 2014

Copy link
Copy Markdown
Contributor

Sounds like it would be OK to just fix this in Bio.Phylo.NewickIO without a
deprecation phase. Would it also be possible to make the same change to
Bio.Nexus.Trees, so the behavior is consistent across Biopython?

On Mon, Sep 22, 2014 at 3:40 AM, Frank [email protected] wrote:

I think (without looking at the code) this is because these values
(separated with a column) originally were to be interpreted as branch
lengths and confidence values, which is on purpose. Support for labels was
added later (was that me, actually...?).

—
Reply to this email directly or view it on GitHub
#360 (comment).

@etal

etal commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

Merged. Thanks, everyone.

I would like to make the equivalent change in Bio.Nexus.Trees to keep the behavior consistent, but I'm not sure how to do it. Would anyone else like to give it a shot?

@peterjc

peterjc commented Aug 30, 2019

Copy link
Copy Markdown
Member

@bsmith89 would you agree to dual license your Biopython contributions as discussed on #898 so we can switch to the standard 3-clause BSD license?

(Apologies if you already have done so, and I have overlooked this)

@peterjc

peterjc commented Sep 3, 2019

Copy link
Copy Markdown
Member

RE: #898 (comment) - Thank you Byron!

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.

5 participants