phylogenie 2.1.15__tar.gz → 2.1.17__tar.gz
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.
- {phylogenie-2.1.15 → phylogenie-2.1.17}/PKG-INFO +1 -1
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/plot.py +4 -5
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/tree.py +9 -5
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/utils.py +1 -1
- {phylogenie-2.1.15 → phylogenie-2.1.17}/pyproject.toml +1 -1
- {phylogenie-2.1.15 → phylogenie-2.1.17}/LICENSE.txt +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/README.md +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/__init__.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/__init__.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/alisim.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/configs.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/dataset.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/factories.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/trees.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/generators/typeguards.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/io.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/main.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/models.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/msa.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/py.typed +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/skyline/__init__.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/skyline/matrix.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/skyline/parameter.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/skyline/vector.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/__init__.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/events/__init__.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/events/contact_tracing.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/events/core.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/events/mutations.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/features.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/gillespie.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/treesimulator/model.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/typeguards.py +0 -0
- {phylogenie-2.1.15 → phylogenie-2.1.17}/phylogenie/typings.py +0 -0
|
@@ -6,7 +6,7 @@ import matplotlib.pyplot as plt
|
|
|
6
6
|
from matplotlib.axes import Axes
|
|
7
7
|
|
|
8
8
|
from phylogenie.tree import Tree
|
|
9
|
-
from phylogenie.utils import get_node_depths
|
|
9
|
+
from phylogenie.utils import get_node_depth_levels, get_node_depths
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class Coloring(str, Enum):
|
|
@@ -22,15 +22,14 @@ def plot_tree(
|
|
|
22
22
|
coloring: str | Coloring | None = None,
|
|
23
23
|
cmap: str | None = None,
|
|
24
24
|
show_legend: bool = True,
|
|
25
|
-
x_feature: str | None = None,
|
|
26
25
|
) -> Axes:
|
|
27
26
|
if ax is None:
|
|
28
27
|
ax = plt.gca()
|
|
29
28
|
|
|
30
29
|
xs = (
|
|
31
|
-
|
|
32
|
-
if
|
|
33
|
-
else
|
|
30
|
+
get_node_depth_levels(tree)
|
|
31
|
+
if any(node.branch_length is None for node in tree)
|
|
32
|
+
else get_node_depths(tree)
|
|
34
33
|
)
|
|
35
34
|
ys = {node: i for i, node in enumerate(tree.inorder_traversal())}
|
|
36
35
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from collections import deque
|
|
2
|
-
from collections.abc import Iterator
|
|
2
|
+
from collections.abc import Callable, Iterator
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
5
|
|
|
@@ -26,7 +26,7 @@ class Tree:
|
|
|
26
26
|
@property
|
|
27
27
|
def depth(self) -> float:
|
|
28
28
|
if self.parent is None:
|
|
29
|
-
return 0.
|
|
29
|
+
return 0 if self.branch_length is None else self.branch_length
|
|
30
30
|
if self.branch_length is None:
|
|
31
31
|
raise ValueError(f"Branch length of node {self.name} is not set.")
|
|
32
32
|
return self.parent.depth + self.branch_length
|
|
@@ -56,6 +56,10 @@ class Tree:
|
|
|
56
56
|
return 0
|
|
57
57
|
return 1 + max(child.height_level for child in self.children)
|
|
58
58
|
|
|
59
|
+
@property
|
|
60
|
+
def n_leaves(self) -> int:
|
|
61
|
+
return len(self.get_leaves())
|
|
62
|
+
|
|
59
63
|
def set(self, key: str, value: Any) -> None:
|
|
60
64
|
self._features[key] = value
|
|
61
65
|
|
|
@@ -122,10 +126,10 @@ class Tree:
|
|
|
122
126
|
def get_leaves(self) -> tuple["Tree", ...]:
|
|
123
127
|
return tuple(node for node in self if node.is_leaf())
|
|
124
128
|
|
|
125
|
-
def ladderize(self,
|
|
126
|
-
self._children.sort(key=
|
|
129
|
+
def ladderize(self, criterion: Callable[["Tree"], Any]) -> None:
|
|
130
|
+
self._children.sort(key=criterion)
|
|
127
131
|
for child in self.children:
|
|
128
|
-
child.ladderize(
|
|
132
|
+
child.ladderize(criterion)
|
|
129
133
|
|
|
130
134
|
def copy(self):
|
|
131
135
|
new_tree = Tree(self.name, self.branch_length)
|
|
@@ -22,7 +22,7 @@ def get_node_depths(tree: Tree) -> dict[Tree, float]:
|
|
|
22
22
|
depths: dict[Tree, float] = {}
|
|
23
23
|
for node in tree:
|
|
24
24
|
if node.parent is None:
|
|
25
|
-
depths[node] = 0
|
|
25
|
+
depths[node] = 0 if node.branch_length is None else node.branch_length
|
|
26
26
|
else:
|
|
27
27
|
if node.branch_length is None:
|
|
28
28
|
raise ValueError(f"Branch length of node {node.name} is not set.")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|