jeetsukumaran / DendroPy

A Python library for phylogenetic scripting, simulation, data processing and manipulation.
https://pypi.org/project/DendroPy/.
BSD 3-Clause "New" or "Revised" License
210 stars 61 forks source link

resolve_polytomies inconsistently creates 0-length branches #72

Closed hyanwong closed 7 years ago

hyanwong commented 7 years ago

In python3/dendropy 4.1.0 (NB: I couldn't find 4.2.0 in the https://pypi.python.org repo, despite what is written on the dendropy home page), when resolve_polytomies() is called with no arguments it creates 0-length branches (which is what I prefer, and would expect). When it is called with an rng argument, the newly created edges have no length, however.

from dendropy import Tree
import random
t1 = Tree.get_from_string("((A,B,C),D);", schema="newick")
t1.resolve_polytomies()
print(t1.as_string(schema="newick")) #contains 0-length branches, where polytomies have been resolved
r = random.Random()
r.seed(1234)
t2 = Tree.get_from_string("((A,B,C),D);", schema="newick")
t2.resolve_polytomies(rng=r)
print(t2.as_string(schema="newick")) #no 0-length branches

I presume there should be some consistency here. Personally, I would prefer t2 to be in the style of t1, with zero-length edges, although I could see that setting either length = 0 or length = None might be a further useful switch to the resolve_polytomies() method.

jeetsukumaran commented 7 years ago

Thanks for pointing this out.

This has been resolved in the latest revision: 4b1acef .

Note that the latest version (4.2.0 and beyond) is always available from GitHub, either on the master branch (public release) or development-master (the apical tip, and usually safe to use, preferentially even, due to the latest fixes and fixings).

PyPi version, yes, is lagging. Will push 4.2.0 soon.

On 12/22/16 5:30 PM, Yan Wong wrote:

In dendropy 4.1.0 (NB: I couldn't find 4.2.0 in the https://pypi.python.org repo, despite what is written on the dendropy home page), when resolve_polytomies() is called with no arguments it creates 0-length branches (which is what I prefer, and would expect). When it is called with an rng argument, the newly created edges have no length, however.

|from dendropy import Tree import random t1 = Tree.get_from_string("((A,B,C),D);", schema="newick") t1.resolve_polytomies() print(t1.as_string(schema="newick")) #contains 0-length branches, where polytomies have been resolved r = random.Random() r.seed(1234) t2 = Tree.get_from_string("((A,B,C),D);", schema="newick") t2.resolve_polytomies(rng=r) print(t2.as_string(schema="newick")) #no 0-length branches |

I presume there should be some consistency here. Personally, I would prefer t2 to be in the style of t1, with zero-length edges, although I could see that setting either length = 0 or length = None might be a further useful switch to the resolve_polytomies() method.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jeetsukumaran/DendroPy/issues/72, or mute the thread https://github.com/notifications/unsubscribe-auth/AABmR0A00Xyx3NpD5xoY_1EEoIQRSbSxks5rKvn4gaJpZM4LUbrn.

--


Jeet Sukumaran

jeetsukumaran@gmail.com

Blog/Personal Pages: http://jeetworks.org/ GitHub Repositories: http://github.com/jeetsukumaran Photographs (as stream): http://www.flickr.com/photos/jeetsukumaran/ Photographs (by galleries): http://www.flickr.com/photos/jeetsukumaran/sets/

hyanwong commented 7 years ago

Thanks for the quick response and fix. I'll use the github version for now.