phylogenie 2.1.26__py3-none-any.whl → 2.1.27__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.
- phylogenie/generators/factories.py +9 -4
- phylogenie/generators/trees.py +6 -2
- phylogenie/treesimulator/events/base.py +0 -2
- phylogenie/treesimulator/events/contact_tracing.py +2 -2
- phylogenie/treesimulator/events/mutations.py +12 -4
- {phylogenie-2.1.26.dist-info → phylogenie-2.1.27.dist-info}/METADATA +1 -1
- {phylogenie-2.1.26.dist-info → phylogenie-2.1.27.dist-info}/RECORD +10 -10
- {phylogenie-2.1.26.dist-info → phylogenie-2.1.27.dist-info}/LICENSE.txt +0 -0
- {phylogenie-2.1.26.dist-info → phylogenie-2.1.27.dist-info}/WHEEL +0 -0
- {phylogenie-2.1.26.dist-info → phylogenie-2.1.27.dist-info}/entry_points.txt +0 -0
|
@@ -17,7 +17,7 @@ from phylogenie.skyline import (
|
|
|
17
17
|
SkylineVector,
|
|
18
18
|
SkylineVectorCoercible,
|
|
19
19
|
)
|
|
20
|
-
from phylogenie.treesimulator import Mutation
|
|
20
|
+
from phylogenie.treesimulator import EventType, Mutation
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def _eval_expression(expression: str, data: dict[str, Any]) -> Any:
|
|
@@ -223,16 +223,21 @@ def distribution(x: Distribution, data: dict[str, Any]) -> Distribution:
|
|
|
223
223
|
|
|
224
224
|
|
|
225
225
|
def mutations(
|
|
226
|
-
x: list[cfg.Mutation],
|
|
226
|
+
x: list[cfg.Mutation],
|
|
227
|
+
data: dict[str, Any],
|
|
228
|
+
states: set[str],
|
|
229
|
+
rates_to_log: list[EventType] | None,
|
|
227
230
|
) -> list[Mutation]:
|
|
228
231
|
mutations: list[Mutation] = []
|
|
229
232
|
for m in x:
|
|
230
233
|
rate = skyline_parameter(m.rate, data)
|
|
231
234
|
rate_scalers = {k: distribution(v, data) for k, v in m.rate_scalers.items()}
|
|
232
235
|
if m.state is None:
|
|
233
|
-
mutations.extend(
|
|
236
|
+
mutations.extend(
|
|
237
|
+
Mutation(s, rate, rate_scalers, rates_to_log) for s in states
|
|
238
|
+
)
|
|
234
239
|
else:
|
|
235
|
-
mutations.append(Mutation(m.state, rate, rate_scalers))
|
|
240
|
+
mutations.append(Mutation(m.state, rate, rate_scalers, rates_to_log))
|
|
236
241
|
return mutations
|
|
237
242
|
|
|
238
243
|
|
phylogenie/generators/trees.py
CHANGED
|
@@ -23,6 +23,7 @@ from phylogenie.models import Distribution
|
|
|
23
23
|
from phylogenie.tree import Tree
|
|
24
24
|
from phylogenie.treesimulator import (
|
|
25
25
|
Event,
|
|
26
|
+
EventType,
|
|
26
27
|
Feature,
|
|
27
28
|
get_BD_events,
|
|
28
29
|
get_BDEI_events,
|
|
@@ -48,6 +49,7 @@ class ParameterizationType(str, Enum):
|
|
|
48
49
|
class TreeDatasetGenerator(DatasetGenerator):
|
|
49
50
|
data_type: Literal[DataType.TREES] = DataType.TREES
|
|
50
51
|
mutations: list[cfg.Mutation] = Field(default_factory=lambda: [])
|
|
52
|
+
rates_to_log: list[EventType] | None = None
|
|
51
53
|
min_tips: cfg.Integer = 1
|
|
52
54
|
max_tips: cfg.Integer | None = None
|
|
53
55
|
max_time: cfg.Scalar = np.inf
|
|
@@ -67,9 +69,11 @@ class TreeDatasetGenerator(DatasetGenerator):
|
|
|
67
69
|
if self.init_state is None
|
|
68
70
|
else self.init_state.format(**data)
|
|
69
71
|
)
|
|
70
|
-
|
|
72
|
+
events = self._get_events(data)
|
|
73
|
+
states = {e.state for e in events}
|
|
74
|
+
events += mutations(self.mutations, data, states, self.rates_to_log)
|
|
71
75
|
return simulate_tree(
|
|
72
|
-
events=
|
|
76
|
+
events=events,
|
|
73
77
|
min_tips=integer(self.min_tips, data),
|
|
74
78
|
max_tips=None if self.max_tips is None else integer(self.max_tips, data),
|
|
75
79
|
max_time=scalar(self.max_time, data),
|
|
@@ -23,7 +23,7 @@ def is_CT_state(state: str) -> bool:
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class BirthWithContactTracing(Event):
|
|
26
|
-
type = EventType.
|
|
26
|
+
type = EventType.BIRTH
|
|
27
27
|
|
|
28
28
|
def __init__(self, state: str, rate: SkylineParameterLike, child_state: str):
|
|
29
29
|
super().__init__(state, rate)
|
|
@@ -42,7 +42,7 @@ class BirthWithContactTracing(Event):
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class SamplingWithContactTracing(Event):
|
|
45
|
-
type = EventType.
|
|
45
|
+
type = EventType.SAMPLING
|
|
46
46
|
|
|
47
47
|
def __init__(
|
|
48
48
|
self,
|
|
@@ -43,9 +43,11 @@ class Mutation(Event):
|
|
|
43
43
|
state: str,
|
|
44
44
|
rate: SkylineParameterLike,
|
|
45
45
|
rate_scalers: dict[EventType, Distribution],
|
|
46
|
+
rates_to_log: list[EventType] | None = None,
|
|
46
47
|
):
|
|
47
48
|
super().__init__(state, rate)
|
|
48
49
|
self.rate_scalers = rate_scalers
|
|
50
|
+
self.rates_to_log = [] if rates_to_log is None else rates_to_log
|
|
49
51
|
|
|
50
52
|
def apply(
|
|
51
53
|
self, model: Model, events: list[Event], time: float, rng: Generator
|
|
@@ -73,18 +75,24 @@ class Mutation(Event):
|
|
|
73
75
|
|
|
74
76
|
if isinstance(event, Birth | BirthWithContactTracing):
|
|
75
77
|
event.child_state = _get_mutated_state(mutation_id, event.child_state)
|
|
78
|
+
metadata_key = f"birth_rate_from_{event.state}_to_{event.child_state}"
|
|
76
79
|
elif isinstance(event, Migration):
|
|
77
80
|
event.target_state = _get_mutated_state(mutation_id, event.target_state)
|
|
78
|
-
|
|
81
|
+
metadata_key = (
|
|
82
|
+
f"migration_rate_from_{event.state}_to_{event.target_state}"
|
|
83
|
+
)
|
|
84
|
+
elif isinstance(
|
|
79
85
|
event, Mutation | Death | Sampling | SamplingWithContactTracing
|
|
80
86
|
):
|
|
87
|
+
metadata_key = f"{event.type}_rate_for_{event.state}"
|
|
88
|
+
else:
|
|
81
89
|
raise ValueError(
|
|
82
90
|
f"Mutation not implemented for event of type {type(event)}."
|
|
83
91
|
)
|
|
84
92
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
metadata[
|
|
93
|
+
event.rate *= rate_scalers.get(event.type, 1)
|
|
94
|
+
if event.type in self.rates_to_log:
|
|
95
|
+
metadata[metadata_key] = (
|
|
88
96
|
event.rate.value[0]
|
|
89
97
|
if len(event.rate.value) == 1
|
|
90
98
|
else list(event.rate.value)
|
|
@@ -4,8 +4,8 @@ phylogenie/generators/__init__.py,sha256=zsOxy28-9j9alOQLIgrOAFfmM58NNHO_NEtW-KX
|
|
|
4
4
|
phylogenie/generators/alisim.py,sha256=1YQLpOG_Bpn9YqExQqEu-wz1MDGCbpPmTdhrBb6TbWc,2820
|
|
5
5
|
phylogenie/generators/configs.py,sha256=zjNnljBBC-d6DTjWjieE8-HnKeE58LAy3moBYiD6NFo,1042
|
|
6
6
|
phylogenie/generators/dataset.py,sha256=kY92diePr2IjiLejHLixJoYRc-2LpM-GBt3wkX9SYvA,2109
|
|
7
|
-
phylogenie/generators/factories.py,sha256=
|
|
8
|
-
phylogenie/generators/trees.py,sha256=
|
|
7
|
+
phylogenie/generators/factories.py,sha256=qSz-s7ltQwUf7R6TPZ-5xFyOnnSHkKn0u5IukeysXVU,8544
|
|
8
|
+
phylogenie/generators/trees.py,sha256=zsmL3_YUUwtn-_NrGSvwZVSGIm9kpf8SPHxoQCIT_hE,10168
|
|
9
9
|
phylogenie/generators/typeguards.py,sha256=yj4VkhOaUXJ2OrY-6zhOeY9C4yKIQxjZtk2d-vIxttQ,828
|
|
10
10
|
phylogenie/io/__init__.py,sha256=gtRYtDdZSTlWCj3I4vmMJSAs93jdz5RySkCakD3sxlQ,214
|
|
11
11
|
phylogenie/io/fasta.py,sha256=IWtNb_RQLR6kvS0G826wB9SodkCGfugddoUHx78Yrec,837
|
|
@@ -22,18 +22,18 @@ phylogenie/skyline/vector.py,sha256=60jtp7PieiEaEH0Tp6zNjNKjyzpN_nT5uwBUXbgeATk,
|
|
|
22
22
|
phylogenie/tree.py,sha256=P1uM6s32TsODpvNJQIPMix9oj39vGSw_wsHYp2wmy5U,5246
|
|
23
23
|
phylogenie/treesimulator/__init__.py,sha256=0wU1PECAcM5rBg5MmeA3poWgfGDzqHySmSJjJs1wkPw,1088
|
|
24
24
|
phylogenie/treesimulator/events/__init__.py,sha256=w2tJ0D2WB5AiCbr3CsKN6vdADueiAEMzd_ve0rpa4zg,939
|
|
25
|
-
phylogenie/treesimulator/events/base.py,sha256=
|
|
26
|
-
phylogenie/treesimulator/events/contact_tracing.py,sha256=
|
|
25
|
+
phylogenie/treesimulator/events/base.py,sha256=Rb9qO0EURKGbFPv_KuRrzZv5Krl1ZEMj8ASHXlBLhbI,1259
|
|
26
|
+
phylogenie/treesimulator/events/contact_tracing.py,sha256=QqinLfQmBBi6qF3nFE_Qsiyd6RUG0RJqxiBOKK0nRGE,5196
|
|
27
27
|
phylogenie/treesimulator/events/core.py,sha256=bhgQgi5L-oaHsoWJmUOsTTzWxi0POYxVLoF-KrC8AGQ,8179
|
|
28
|
-
phylogenie/treesimulator/events/mutations.py,sha256=
|
|
28
|
+
phylogenie/treesimulator/events/mutations.py,sha256=fGxxeXhiFrMAaS-s_vd42aVBZ6XQiRjpW9uJUATNk1E,3752
|
|
29
29
|
phylogenie/treesimulator/features.py,sha256=nNfv0kPudAZnrnufIVuFCR_VEJSP-6fZ2L-VG5_-Fqo,1366
|
|
30
30
|
phylogenie/treesimulator/gillespie.py,sha256=_O1TqK-LOjH6k8ZSos-CbVQ7wJZPzf1Awv_1DXt0NYE,5730
|
|
31
31
|
phylogenie/treesimulator/model.py,sha256=lhDwmBFQ8Qh8qVGZPgED0vehtPC3DE7_CgCV_8rPB-A,4641
|
|
32
32
|
phylogenie/typeguards.py,sha256=JtqmbEWJZBRHbWgCvcl6nrWm3VcBfzRbklbTBYHItn0,1325
|
|
33
33
|
phylogenie/typings.py,sha256=p694PBe_tk25A6N8vGGWxuqoDtt3nHFUsIYJrwR_76Y,494
|
|
34
34
|
phylogenie/utils.py,sha256=ehVk_2kvjW8Q_EyM2kxBPHYiK-KlPmZQx7JeVN6Fh-E,5419
|
|
35
|
-
phylogenie-2.1.
|
|
36
|
-
phylogenie-2.1.
|
|
37
|
-
phylogenie-2.1.
|
|
38
|
-
phylogenie-2.1.
|
|
39
|
-
phylogenie-2.1.
|
|
35
|
+
phylogenie-2.1.27.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
|
|
36
|
+
phylogenie-2.1.27.dist-info/METADATA,sha256=UUZTU3YJ5yrAzQZ8EiiVsTmhuZzKNiGU_roQazkf3Mo,5477
|
|
37
|
+
phylogenie-2.1.27.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
38
|
+
phylogenie-2.1.27.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
|
|
39
|
+
phylogenie-2.1.27.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|