phylogenie 1.0.8__py3-none-any.whl → 2.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.
- phylogenie/generators/__init__.py +14 -0
- phylogenie/generators/alisim.py +71 -0
- phylogenie/generators/configs.py +41 -0
- phylogenie/{core → generators}/dataset.py +25 -23
- phylogenie/{core → generators}/factories.py +42 -52
- phylogenie/generators/trees.py +220 -0
- phylogenie/generators/typeguards.py +32 -0
- phylogenie/io.py +92 -0
- phylogenie/main.py +2 -2
- phylogenie/msa.py +72 -0
- phylogenie/skyline/matrix.py +62 -45
- phylogenie/skyline/vector.py +8 -6
- phylogenie/tree.py +53 -0
- phylogenie/treesimulator/__init__.py +21 -0
- phylogenie/treesimulator/events.py +256 -0
- phylogenie/treesimulator/gillespie.py +66 -0
- phylogenie/treesimulator/model.py +100 -0
- phylogenie/typings.py +0 -2
- {phylogenie-1.0.8.dist-info → phylogenie-2.0.0.dist-info}/METADATA +6 -18
- phylogenie-2.0.0.dist-info/RECORD +28 -0
- phylogenie/backend/__init__.py +0 -0
- phylogenie/backend/remaster/__init__.py +0 -21
- phylogenie/backend/remaster/generate.py +0 -187
- phylogenie/backend/remaster/reactions.py +0 -165
- phylogenie/backend/treesimulator.py +0 -163
- phylogenie/configs.py +0 -5
- phylogenie/core/__init__.py +0 -14
- phylogenie/core/configs.py +0 -37
- phylogenie/core/context/__init__.py +0 -4
- phylogenie/core/context/configs.py +0 -28
- phylogenie/core/context/distributions.py +0 -125
- phylogenie/core/context/factories.py +0 -54
- phylogenie/core/msas/__init__.py +0 -10
- phylogenie/core/msas/alisim.py +0 -35
- phylogenie/core/msas/base.py +0 -51
- phylogenie/core/trees/__init__.py +0 -11
- phylogenie/core/trees/base.py +0 -13
- phylogenie/core/trees/remaster/__init__.py +0 -3
- phylogenie/core/trees/remaster/configs.py +0 -14
- phylogenie/core/trees/remaster/factories.py +0 -26
- phylogenie/core/trees/remaster/generator.py +0 -177
- phylogenie/core/trees/treesimulator.py +0 -199
- phylogenie/core/typeguards.py +0 -32
- phylogenie-1.0.8.dist-info/RECORD +0 -39
- {phylogenie-1.0.8.dist-info → phylogenie-2.0.0.dist-info}/LICENSE.txt +0 -0
- {phylogenie-1.0.8.dist-info → phylogenie-2.0.0.dist-info}/WHEEL +0 -0
- {phylogenie-1.0.8.dist-info → phylogenie-2.0.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
from typing import Annotated, Literal
|
|
3
|
-
|
|
4
|
-
import numpy as np
|
|
5
|
-
from numpy.random import Generator
|
|
6
|
-
from pydantic import Field
|
|
7
|
-
|
|
8
|
-
import phylogenie.core.configs as cfg
|
|
9
|
-
import phylogenie.typings as pgt
|
|
10
|
-
from phylogenie.backend.treesimulator import (
|
|
11
|
-
DEFAULT_POPULATION,
|
|
12
|
-
TreeParams,
|
|
13
|
-
generate_tree,
|
|
14
|
-
get_BD_params,
|
|
15
|
-
get_BDEI_params,
|
|
16
|
-
get_BDSS_params,
|
|
17
|
-
)
|
|
18
|
-
from phylogenie.core.factories import (
|
|
19
|
-
int_factory,
|
|
20
|
-
scalar_factory,
|
|
21
|
-
skyline_matrix_coercible_factory,
|
|
22
|
-
skyline_parameter_like_factory,
|
|
23
|
-
skyline_vector_coercible_factory,
|
|
24
|
-
)
|
|
25
|
-
from phylogenie.core.trees.base import BackendType, TreesGenerator
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class ParameterizationType(str, Enum):
|
|
29
|
-
MTBD = "MTBD"
|
|
30
|
-
BD = "BD"
|
|
31
|
-
BDEI = "BDEI"
|
|
32
|
-
BDSS = "BDSS"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class TreeSimulatorGenerator(TreesGenerator):
|
|
36
|
-
backend: Literal[BackendType.TREESIMULATOR] = BackendType.TREESIMULATOR
|
|
37
|
-
min_tips: cfg.IntConfig
|
|
38
|
-
max_tips: cfg.IntConfig
|
|
39
|
-
T: cfg.ScalarConfig = np.inf
|
|
40
|
-
root_state: str | None = None
|
|
41
|
-
state_frequencies: list[float] | None = None
|
|
42
|
-
notification_probability: cfg.SkylineParameterLikeConfig = 0
|
|
43
|
-
notification_sampling_rate: cfg.SkylineParameterLikeConfig = np.inf
|
|
44
|
-
allow_irremovable_states: bool = False
|
|
45
|
-
max_notified_contacts: cfg.IntConfig = 1
|
|
46
|
-
|
|
47
|
-
def _generate_one_from_params(
|
|
48
|
-
self, filename: str, rng: Generator, data: pgt.Data, params: TreeParams
|
|
49
|
-
) -> None:
|
|
50
|
-
root_state = (
|
|
51
|
-
self.root_state
|
|
52
|
-
if self.root_state is None
|
|
53
|
-
else self.root_state.format(**data)
|
|
54
|
-
)
|
|
55
|
-
generate_tree(
|
|
56
|
-
output_file=f"{filename}.nwk",
|
|
57
|
-
params=params,
|
|
58
|
-
min_tips=int_factory(self.min_tips, data),
|
|
59
|
-
max_tips=int_factory(self.max_tips, data),
|
|
60
|
-
T=scalar_factory(self.T, data),
|
|
61
|
-
state_frequencies=self.state_frequencies,
|
|
62
|
-
notification_probability=skyline_parameter_like_factory(
|
|
63
|
-
self.notification_probability, data
|
|
64
|
-
),
|
|
65
|
-
notification_sampling_rate=skyline_parameter_like_factory(
|
|
66
|
-
self.notification_sampling_rate, data
|
|
67
|
-
),
|
|
68
|
-
allow_irremovable_states=self.allow_irremovable_states,
|
|
69
|
-
max_notified_contacts=int_factory(self.max_notified_contacts, data),
|
|
70
|
-
root_state=root_state,
|
|
71
|
-
random_seed=int(rng.integers(0, 2**31 - 1)),
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class MTBDTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
76
|
-
parameterization: Literal[ParameterizationType.MTBD] = ParameterizationType.MTBD
|
|
77
|
-
populations: str | list[str] = DEFAULT_POPULATION
|
|
78
|
-
transmission_rates: cfg.SkylineMatrixCoercibleConfig
|
|
79
|
-
removal_rates: cfg.SkylineVectorCoercibleConfig
|
|
80
|
-
transition_rates: cfg.SkylineMatrixCoercibleConfig = 0
|
|
81
|
-
sampling_proportions: cfg.SkylineVectorCoercibleConfig = 1
|
|
82
|
-
|
|
83
|
-
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
84
|
-
self._generate_one_from_params(
|
|
85
|
-
filename,
|
|
86
|
-
rng,
|
|
87
|
-
data,
|
|
88
|
-
TreeParams(
|
|
89
|
-
populations=self.populations,
|
|
90
|
-
transition_rates=skyline_matrix_coercible_factory(
|
|
91
|
-
self.transition_rates, data
|
|
92
|
-
),
|
|
93
|
-
transmission_rates=skyline_matrix_coercible_factory(
|
|
94
|
-
self.transmission_rates, data
|
|
95
|
-
),
|
|
96
|
-
removal_rates=skyline_vector_coercible_factory(
|
|
97
|
-
self.removal_rates, data
|
|
98
|
-
),
|
|
99
|
-
sampling_proportions=skyline_vector_coercible_factory(
|
|
100
|
-
self.sampling_proportions, data
|
|
101
|
-
),
|
|
102
|
-
),
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
class BDTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
107
|
-
parameterization: Literal[ParameterizationType.BD] = ParameterizationType.BD
|
|
108
|
-
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
109
|
-
infectious_period: cfg.SkylineParameterLikeConfig
|
|
110
|
-
sampling_proportion: cfg.SkylineParameterLikeConfig = 1
|
|
111
|
-
|
|
112
|
-
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
113
|
-
self._generate_one_from_params(
|
|
114
|
-
filename,
|
|
115
|
-
rng,
|
|
116
|
-
data,
|
|
117
|
-
get_BD_params(
|
|
118
|
-
reproduction_number=skyline_parameter_like_factory(
|
|
119
|
-
self.reproduction_number, data
|
|
120
|
-
),
|
|
121
|
-
infectious_period=skyline_parameter_like_factory(
|
|
122
|
-
self.infectious_period, data
|
|
123
|
-
),
|
|
124
|
-
sampling_proportion=skyline_parameter_like_factory(
|
|
125
|
-
self.sampling_proportion, data
|
|
126
|
-
),
|
|
127
|
-
),
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
class BDEITreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
132
|
-
parameterization: Literal[ParameterizationType.BDEI] = ParameterizationType.BDEI
|
|
133
|
-
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
134
|
-
infectious_period: cfg.SkylineParameterLikeConfig
|
|
135
|
-
incubation_period: cfg.SkylineParameterLikeConfig
|
|
136
|
-
sampling_proportion: cfg.SkylineParameterLikeConfig = 1
|
|
137
|
-
|
|
138
|
-
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
139
|
-
self._generate_one_from_params(
|
|
140
|
-
filename,
|
|
141
|
-
rng,
|
|
142
|
-
data,
|
|
143
|
-
get_BDEI_params(
|
|
144
|
-
reproduction_number=skyline_parameter_like_factory(
|
|
145
|
-
self.reproduction_number, data
|
|
146
|
-
),
|
|
147
|
-
infectious_period=skyline_parameter_like_factory(
|
|
148
|
-
self.infectious_period, data
|
|
149
|
-
),
|
|
150
|
-
incubation_period=skyline_parameter_like_factory(
|
|
151
|
-
self.incubation_period, data
|
|
152
|
-
),
|
|
153
|
-
sampling_proportion=skyline_parameter_like_factory(
|
|
154
|
-
self.sampling_proportion, data
|
|
155
|
-
),
|
|
156
|
-
),
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
class BDSSTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
161
|
-
parameterization: Literal[ParameterizationType.BDSS] = ParameterizationType.BDSS
|
|
162
|
-
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
163
|
-
infectious_period: cfg.SkylineParameterLikeConfig
|
|
164
|
-
superspreading_ratio: cfg.SkylineParameterLikeConfig
|
|
165
|
-
superspreaders_proportion: cfg.SkylineParameterLikeConfig
|
|
166
|
-
sampling_proportion: cfg.SkylineParameterLikeConfig = 1
|
|
167
|
-
|
|
168
|
-
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
169
|
-
self._generate_one_from_params(
|
|
170
|
-
filename,
|
|
171
|
-
rng,
|
|
172
|
-
data,
|
|
173
|
-
get_BDSS_params(
|
|
174
|
-
reproduction_number=skyline_parameter_like_factory(
|
|
175
|
-
self.reproduction_number, data
|
|
176
|
-
),
|
|
177
|
-
infectious_period=skyline_parameter_like_factory(
|
|
178
|
-
self.infectious_period, data
|
|
179
|
-
),
|
|
180
|
-
superspreading_ratio=skyline_parameter_like_factory(
|
|
181
|
-
self.superspreading_ratio, data
|
|
182
|
-
),
|
|
183
|
-
superspreaders_proportion=skyline_parameter_like_factory(
|
|
184
|
-
self.superspreaders_proportion, data
|
|
185
|
-
),
|
|
186
|
-
sampling_proportion=skyline_parameter_like_factory(
|
|
187
|
-
self.sampling_proportion, data
|
|
188
|
-
),
|
|
189
|
-
),
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
TreeSimulatorGeneratorConfig = Annotated[
|
|
194
|
-
MTBDTreeSimulatorGenerator
|
|
195
|
-
| BDTreeSimulatorGenerator
|
|
196
|
-
| BDEITreeSimulatorGenerator
|
|
197
|
-
| BDSSTreeSimulatorGenerator,
|
|
198
|
-
Field(discriminator="parameterization"),
|
|
199
|
-
]
|
phylogenie/core/typeguards.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
from typing import TypeGuard
|
|
2
|
-
|
|
3
|
-
import phylogenie.core.configs as cfg
|
|
4
|
-
import phylogenie.typings as pgt
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def is_list(x: object) -> TypeGuard[list[object]]:
|
|
8
|
-
return isinstance(x, list)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def is_list_of_scalar_configs(x: object) -> TypeGuard[list[cfg.ScalarConfig]]:
|
|
12
|
-
return is_list(x) and all(isinstance(v, cfg.ScalarConfig) for v in x)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def is_list_of_skyline_parameter_like_configs(
|
|
16
|
-
x: object,
|
|
17
|
-
) -> TypeGuard[list[cfg.SkylineParameterLikeConfig]]:
|
|
18
|
-
return is_list(x) and all(isinstance(v, cfg.SkylineParameterLikeConfig) for v in x)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def is_skyline_vector_coercible_config(
|
|
22
|
-
x: object,
|
|
23
|
-
) -> TypeGuard[cfg.SkylineVectorCoercibleConfig]:
|
|
24
|
-
return isinstance(
|
|
25
|
-
x, str | pgt.Scalar | cfg.SkylineVectorValueModel
|
|
26
|
-
) or is_list_of_skyline_parameter_like_configs(x)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def is_list_of_skyline_vector_coercible_configs(
|
|
30
|
-
x: object,
|
|
31
|
-
) -> TypeGuard[list[cfg.SkylineVectorCoercibleConfig]]:
|
|
32
|
-
return is_list(x) and all(is_skyline_vector_coercible_config(v) for v in x)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
phylogenie/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
phylogenie/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
phylogenie/backend/remaster/__init__.py,sha256=g1oMKi6SX60Geq_e2AjBlf7-pDvLfrsT3gW6AORdbMo,509
|
|
4
|
-
phylogenie/backend/remaster/generate.py,sha256=jDtcZyi6ifptRopeuGCHETzVz_NyK4UC3HiNPwQPzbg,6109
|
|
5
|
-
phylogenie/backend/remaster/reactions.py,sha256=oc2ZY9WtTajbOWjARDmA0JnS255tbVeMt1DmyCUp95M,5904
|
|
6
|
-
phylogenie/backend/treesimulator.py,sha256=pJmSX_0EOFngJTCxh36qTap1llYIZq4p9azQ9PIjlo4,5469
|
|
7
|
-
phylogenie/configs.py,sha256=HtRUWZ-zNq1--zTBWL3QFXX27Ybw5x1qSWcmx7Sz8YA,125
|
|
8
|
-
phylogenie/core/__init__.py,sha256=pvQMohKFAPaSvujw7H5sQJn7SOSqENQUHECuVfUBVNg,402
|
|
9
|
-
phylogenie/core/configs.py,sha256=9tUYWrmdDn_Gg6xnywCDcGDEk0gne0vYqFH9dXixJbM,1042
|
|
10
|
-
phylogenie/core/context/__init__.py,sha256=ZiCweJgf1REKbhZTfHuzz1lIgVmio9bTYW3-srOUqUo,168
|
|
11
|
-
phylogenie/core/context/configs.py,sha256=TEJZykoNLy-77nVWqjrZuoFhJLRggJuFA_GLMPDrUVM,570
|
|
12
|
-
phylogenie/core/context/distributions.py,sha256=zQrUXDqQH_Goz0jGFb1tUMUU0YPOG4rMIilR8DDmQp4,3037
|
|
13
|
-
phylogenie/core/context/factories.py,sha256=I6J3e_ZWdETehiSXH9pCVPBuun6vHpuyC48zjayKMX8,1752
|
|
14
|
-
phylogenie/core/dataset.py,sha256=mgPAexXTat6x7YB9-BI6d5HWwrAvt8xydmiWVzwVD3M,2431
|
|
15
|
-
phylogenie/core/factories.py,sha256=DwuocGd48Ham7wD7uyGnGA0tHvXhzuP1Ji0PW5-onwM,7397
|
|
16
|
-
phylogenie/core/msas/__init__.py,sha256=-2XjTmiTA6zAwiLs2ksKecCrSbNLheo7KKjDyvuLipg,207
|
|
17
|
-
phylogenie/core/msas/alisim.py,sha256=TG4LAHJaH3rGWa3cwXzX6MgaXuh2tLzhdoALyOkoiXY,1047
|
|
18
|
-
phylogenie/core/msas/base.py,sha256=Mw7bI4PU7J4b5mrsd0kMkJVJk7bqmJQZFtZ91I8oRS0,1597
|
|
19
|
-
phylogenie/core/trees/__init__.py,sha256=epKgJ-EI04kBEuS4kfBcnsAj7dMObT1T742peBAnB78,335
|
|
20
|
-
phylogenie/core/trees/base.py,sha256=sNBCJRtWGYaMog4WoyAkrK4F2SXrgjXrxjuVQ6Ae5Js,305
|
|
21
|
-
phylogenie/core/trees/remaster/__init__.py,sha256=FfgXYjkeosb22Anbp78re2NssWtNcNNaj7hFQZx8JLE,116
|
|
22
|
-
phylogenie/core/trees/remaster/configs.py,sha256=d4EqowYMb5I2TfBTgNf9H_X1t8aNCYJbh1RQmFoDxs4,362
|
|
23
|
-
phylogenie/core/trees/remaster/factories.py,sha256=qla4pg4OgfE5lwQZuP3bEaMt7xIF4P6fQ1Z0IPpFxUs,812
|
|
24
|
-
phylogenie/core/trees/remaster/generator.py,sha256=UJO9ymxHE3lS62RgyJ-cS2Tc_RbHgxeGggx_Ses6k4Q,7259
|
|
25
|
-
phylogenie/core/trees/treesimulator.py,sha256=RpyRvXAHLHEOU9Ub9Yg61au7xP_rnbC7N0va43gbbx8,7319
|
|
26
|
-
phylogenie/core/typeguards.py,sha256=wEBYJZZ_Q_bY7ZJSh00AXJeyc1X8ZoysoOiLwo24N1w,990
|
|
27
|
-
phylogenie/main.py,sha256=n_joau3dWJIq0ZMHe4a_1_2GigTFagkfzUFuQEMlyRI,1158
|
|
28
|
-
phylogenie/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
-
phylogenie/skyline/__init__.py,sha256=7pF4CUb4ZCLzNYJNhOjpuTOLTRhlK7L6ugfccNqjIGo,620
|
|
30
|
-
phylogenie/skyline/matrix.py,sha256=T2g_MtfrqXVVGug40Nka1Q0YrpIi4KKx72Z573J-V18,7999
|
|
31
|
-
phylogenie/skyline/parameter.py,sha256=CJ5OEyRQG2Tg1WJWQ1IpfX-6hjJv80Zj8lMoRke5nnQ,4648
|
|
32
|
-
phylogenie/skyline/vector.py,sha256=Zh6HWoziXQFKDz-XvVE2e_Tw1706NrbwcvBpyPpw_cc,7120
|
|
33
|
-
phylogenie/typeguards.py,sha256=WBOSJSaOC8VDtrYoA2w_AYEXTpyKdCfmsM29KaKXl3A,1350
|
|
34
|
-
phylogenie/typings.py,sha256=93VRedBxrpzXkT4uaNu_1JiMzsOjp7fUy4kLv_eYxUE,565
|
|
35
|
-
phylogenie-1.0.8.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
|
|
36
|
-
phylogenie-1.0.8.dist-info/METADATA,sha256=eEc-ZuAO-y2SKsjHYxqSxRwqMYZ4Y_Hr8wzk49x9I4k,6291
|
|
37
|
-
phylogenie-1.0.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
38
|
-
phylogenie-1.0.8.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
|
|
39
|
-
phylogenie-1.0.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|