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

`split_distribution` crashes with `TypeError` #89

Closed mjr129 closed 6 months ago

mjr129 commented 6 years ago

split_distribution crashes with TypeError

Steps to reproduce

import dendropy
tree_list = dendropy.TreeList()
tree_list.read_from_string( "(((A,B),C),(D,E));", "newick" )
tree_list.read_from_string( "(((A,D),E),(B,C));", "newick" )
split_distribution = tree_list.split_distribution()
split_distribution.consensus_tree()

Expected output

Consensus tree or meaningful error message.

Observed output

TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

Error traceback

  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dendropy/datamodel/treecollectionmodel.py", line 1763, in consensus_tree
    **split_summarization_kwargs
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dendropy/datamodel/treecollectionmodel.py", line 1798, in summarize_splits_on_tree
    is_bipartitions_updated=is_bipartitions_updated)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dendropy/datamodel/treecollectionmodel.py", line 1999, in summarize_splits_on_tree
    edge_length_summaries = split_distribution.split_edge_length_summaries
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dendropy/datamodel/treecollectionmodel.py", line 1591, in _get_split_edge_length_summaries
    self.calc_split_edge_length_summaries()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dendropy/datamodel/treecollectionmodel.py", line 1566, in calc_split_edge_length_summaries
    self._split_edge_length_summaries[split] = statistics.summarize(elens)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dendropy/calculate/statistics.py", line 486, in summarize
    summary['range'] = (min(values), max(values))
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

Related issues

Most other split_distribution functions also fail with the same error, e.g:

split_distribution.summarize_splits_on_tree( tree_list[0] )
jeetsukumaran commented 6 years ago

Thanks for pointing this out. Hotfix in latest development-master revision here: c6a43d5 . Still need to test thoroughly, so use with caution and appreciate any feedback that you might have.

mmore500 commented 6 months ago

Confirmed this is fixed in newer versions of DendroPy.