multree 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: multree
3
+ Version: 1.0.0
4
+ Summary: Reticulate trees (MUL-trees and phylogenetic networks) and measures to compare them
5
+ Author: Ronen Shtein, Tom Ulanovski
6
+ License-Expression: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/Roshex/multree
8
+ Project-URL: Repository, https://github.com/Roshex/multree
9
+ Project-URL: Issues, https://github.com/Roshex/multree/issues
10
+ Keywords: phylogenetics,phylogenetic network,MUL-tree,reticulation,polyploidy
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: ete3>=3.1.2
20
+ Requires-Dist: six
21
+ Requires-Dist: legacy-cgi; python_version >= "3.13"
22
+ Requires-Dist: networkx>=2.8
23
+ Requires-Dist: numpy>=1.22
24
+ Requires-Dist: scipy>=1.8
25
+ Requires-Dist: pandas>=1.4
26
+ Requires-Dist: matplotlib>=3.5
27
+ Requires-Dist: seaborn>=0.12
28
+ Requires-Dist: pyvis>=0.3.1
29
+ Provides-Extra: mu
30
+ Requires-Dist: phylonetwork==2.2.2; python_version < "3.12" and extra == "mu"
31
+ Provides-Extra: test
32
+ Requires-Dist: pytest>=7; extra == "test"
33
+ Dynamic: license-file
34
+
35
+ # multree
36
+
37
+ Reticulate trees - multi-labelled trees (MUL-trees) and phylogenetic networks in extended Newick - and
38
+ measures to compare them: reticulation counts, ploidy differences, reticulation leaves and sisters
39
+ (Jaccard distances after Hungarian matching), the mu-distance, the graph edit distance, and pairwise
40
+ comparison tables and heatmaps.
41
+
42
+ Used by [GRANDMA](https://github.com/Roshex/Grandma), PhyloFold (`phylofold.evaluate`) and the benchmark of
43
+ polyploid network inference methods [polyploid-benchmark](https://github.com/tomulanovski/polyploid-benchmark/).
44
+ In GRANDMA this code was the `Reticulate_Tree` folder.
45
+
46
+ ## Installation
47
+
48
+ Python 3.10 or newer:
49
+
50
+ ```bash
51
+ pip install multree # once released on PyPI
52
+ pip install "git+https://github.com/Roshex/multree.git"
53
+ ```
54
+
55
+ The mu-distance needs `phylonetwork==2.2.2` (`pip install "multree[mu]"`). Its setup fails on
56
+ Python >= 3.12 (its `versioneer.py` uses `SafeConfigParser`): there, install it from the sdist with
57
+ that name changed to `ConfigParser`, or use Python 3.10/3.11. Without phylonetwork everything else
58
+ works; `pairwise_compare` then reports `mu_distance` as NaN and `mu_scored` as 0, with one warning.
59
+
60
+ ## Use
61
+
62
+ ```python
63
+ from multree.reticulate_tree import ReticulateTree
64
+ from multree.compare_reticulations import pairwise_compare
65
+
66
+ truth = ReticulateTree("((A,B),(C,(A,D)));", is_multree=True)
67
+ inferred = ReticulateTree("((A,B),(C,D));")
68
+ print(truth.get_reticulation_count(), truth.get_reticulation_leaves(), truth.get_reticulation_sisters())
69
+ print(pairwise_compare(truth, inferred)) # every metric; edit_distance=False skips the slowest
70
+ print(truth - inferred) # graph edit distance
71
+ ```
72
+
73
+ More in [examples/multree_demo.ipynb](https://github.com/Roshex/multree/blob/HEAD/examples/multree_demo.ipynb).
74
+ Tests: `pip install -e ".[test]"`, then `pytest`.
75
+
76
+ ## Contents
77
+
78
+ | file | contents |
79
+ | --- | --- |
80
+ | `reticulate_tree.py` | `ReticulateTree`: Newick / MUL-tree / extended Newick (#H) / ete3 / networkx input; MUL-tree -> network by HOLM folding (`multree_to_dag`) or Polyphest-style folding (`polyphest_multree_to_dag`); network -> MUL-tree; extended Newick out; reticulation count, leaves and sisters; edit distance (`get_edit_distance`, `a - b`, `get_edit_distance_multree`); mu-distance; plots |
81
+ | `compare_reticulations.py` | `pairwise_compare` and the many-network tables (`pairwise_comparison`, `one_stop_compare`), `are_identical`, heatmaps |
82
+ | `holm_python.py` | earlier standalone HOLM implementation, superseded by `multree_to_dag`; kept for reference |
83
+ | `tests/test_multree.py` | the pairwise checks of PhyloFold's `test_evaluate.py` on the package: both Jaccard modes, mu-distance, `num_rets_bias`, the `edit_distance` switch, `one_stop_compare`, and `visualize` / `visualize2` with `launch=False` |
84
+
85
+ ## Provenance
86
+
87
+ My original code with bug fixes and expansion by Tom Ulanovski in his benchmark copy `polyploid-benchmark`
88
+ is built and expanded, e.g. with the mu metric. This package is Tom's copy as the base,
89
+ with everything of my version that his copy had dropped restored, and one
90
+ bug fixed. It gives the same values as the copy that scored the benchmark tables (Polyphest,
91
+ GRAMPA-iter, AlloppNET, ...).
92
+
93
+ **Ronen** (original files): HOLM folding and the Polyphest-style folding,
94
+ `dag_to_multree`, extended Newick in/out, reticulation count / leaves /
95
+ sisters, leaf counts, the graph edit distance, `pairwise_compare` with
96
+ number of reticulations, ploidy difference (TP/FP/FN), reticulation
97
+ descendants and sisters Jaccard with Hungarian matching,
98
+ `pairwise_comparison`, `one_stop_compare`, `are_identical`, heatmaps,
99
+ `visualize`, `visualize2`, `interact`, `holm_python.py`.
100
+
101
+ **Tom** (benchmark additions):
102
+ - mu-distance: `get_mu_distance`, `get_mu_root_vector`, orchard certificate
103
+ (`is_orchard`, `orchard_certificate`), `compare_mu` -> `mu_distance`, `mu_scored`;
104
+ - `partial_match` for the Jaccard metrics (best-match only, no penalty for
105
+ unmatched reticulations); the benchmark uses it only for
106
+ `SINGLE_RETICULATION_METHODS = {'grampa'}`;
107
+ - `_matched` Jaccard variants, `polyploid_species_jaccard`, `num_rets_bias`;
108
+ - semantics: an autopolyploid node counts as a reticulation, with
109
+ `auto_events` / `allo_events` per node (`get_auto_event_count`,
110
+ `get_allo_event_count`); `compare_num_rets` returns `{'signed', 'abs'}`;
111
+ - `refold=True` (unfold a network to its MUL-tree and fold again);
112
+ `#` accepted in extended Newick labels; `get_edit_distance_multree`.
113
+
114
+ **Restored** (missing in Tom's copy):
115
+ - `visualize(filename=None, uid_labeled=False, launch=True)` (barycentric
116
+ layout) and `visualize2(..., launch=True)`; `launch=False` writes the HTML
117
+ without opening a browser (for clusters and tests);
118
+ - the edit distance in `pairwise_compare` (`edit_distance=True` by default;
119
+ `edit_distance=False` skips it, as Tom's scripts did, because it can
120
+ run for very long on large networks);
121
+ - the "Clustering A/B" example in `compare_reticulations.py`.
122
+
123
+ **Fixed:** `get_edit_distance(normalize=True, timeout=None)` took the
124
+ first value of `nx.optimize_graph_edit_distance`, which is only the first,
125
+ loose upper bound of an anytime search (identical networks written in a
126
+ different order scored 0.67). It now returns the exact minimum
127
+ (`nx.graph_edit_distance`), or the best value found within `timeout`
128
+ seconds. The GED inside the Polyphest-style folding is not checked yet.
129
+ `holm_python.py` imported a module by an old name; it now imports `ReticulateTree` from this
130
+ package. Its `__main__` demo still calls `get_number_of_special_nodes`, which does not exist.
131
+
132
+ **Changed as a package:** the modules import each other within the package (they also still work
133
+ as a plain folder on `sys.path`), and `compare_mu` treats a missing phylonetwork like a pair it
134
+ cannot score (NaN, `mu_scored` 0, one warning) instead of raising, since phylonetwork cannot be
135
+ pip-installed on Python >= 3.12.
136
+
137
+ ## Dependencies
138
+
139
+ ete3 (Python >= 3.13 also needs `legacy-cgi`, installed automatically), networkx, scipy, numpy,
140
+ pandas, matplotlib, seaborn, pyvis; phylonetwork 2.2.2 for the mu-distance (see Installation).
141
+
142
+ ## License
143
+
144
+ MIT License (see [LICENSE](https://github.com/Roshex/multree/blob/HEAD/LICENSE)).
@@ -0,0 +1,9 @@
1
+ multree/__init__.py,sha256=9Ub9pxTu8CiU59t1NLLU1uJGoEIwwmo870wHd0KmSoY,226
2
+ multree/compare_reticulations.py,sha256=TN5wMt9eXvFI6Ha0jq8DGOuJilVXBmXLTObuwYZNkFI,24363
3
+ multree/holm_python.py,sha256=P-EcFIwCt_3zcTZcEU9BOjGp-rYnyw5n5F9P1gVLzkw,9762
4
+ multree/reticulate_tree.py,sha256=bnW85zAdKCfXwEVEuKOYsHQT60FKLUqJFBNE-BOVSdk,62514
5
+ multree-1.0.0.dist-info/licenses/LICENSE,sha256=HfU8nvqAXecpRYUwHew3tc_uAiw3DqH6j7Hm_h0dGKk,1084
6
+ multree-1.0.0.dist-info/METADATA,sha256=RLTRdGnbj9qc7hE9s77vRtR4qhFDLdYMoWwcUm7OTFo,7569
7
+ multree-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ multree-1.0.0.dist-info/top_level.txt,sha256=WNroFYNMN2ZmKUWQWaf5SUBKrGVFFF47pO5u_Zu_j4E,8
9
+ multree-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ronen Shtein and co-authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ multree