phylogenie 1.0.5__tar.gz → 1.0.7__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-1.0.5 → phylogenie-1.0.7}/PKG-INFO +2 -2
- {phylogenie-1.0.5 → phylogenie-1.0.7}/README.md +1 -1
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/backend/treesimulator.py +28 -4
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/msas/base.py +20 -3
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/treesimulator.py +49 -11
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/typings.py +0 -1
- {phylogenie-1.0.5 → phylogenie-1.0.7}/pyproject.toml +1 -1
- {phylogenie-1.0.5 → phylogenie-1.0.7}/LICENSE.txt +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/backend/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/backend/remaster/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/backend/remaster/generate.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/backend/remaster/reactions.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/configs.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/configs.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/context/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/context/configs.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/context/distributions.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/context/factories.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/dataset.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/factories.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/msas/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/msas/alisim.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/base.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/remaster/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/remaster/configs.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/remaster/factories.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/trees/remaster/generator.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/core/typeguards.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/main.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/py.typed +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/skyline/__init__.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/skyline/matrix.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/skyline/parameter.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/skyline/vector.py +0 -0
- {phylogenie-1.0.5 → phylogenie-1.0.7}/phylogenie/typeguards.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: phylogenie
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Generate phylogenetic datasets with minimal setup effort
|
|
5
5
|
Author: Gabriele Marino
|
|
6
6
|
Author-email: gabmarino.8601@gmail.com
|
|
@@ -46,7 +46,7 @@ Phylogenie comes packed with useful features, including:
|
|
|
46
46
|
Simply specify the number of cores to use, and Phylogenie handles multiprocessing automatically.
|
|
47
47
|
|
|
48
48
|
- **Pre-implemented parameterizations** 🎯
|
|
49
|
-
Include canonical, fossilized birth-death, epidemiological, birth-death with exposed-infectious (BDEI), contact-tracing (CT), and more.
|
|
49
|
+
Include canonical, fossilized birth-death, epidemiological, birth-death with exposed-infectious (BDEI), birth-death with superspreading (BDSS), contact-tracing (CT), and more.
|
|
50
50
|
|
|
51
51
|
- **Skyline parameter support** 🪜
|
|
52
52
|
Support for piece-wise constant parameters.
|
|
@@ -27,7 +27,7 @@ Phylogenie comes packed with useful features, including:
|
|
|
27
27
|
Simply specify the number of cores to use, and Phylogenie handles multiprocessing automatically.
|
|
28
28
|
|
|
29
29
|
- **Pre-implemented parameterizations** 🎯
|
|
30
|
-
Include canonical, fossilized birth-death, epidemiological, birth-death with exposed-infectious (BDEI), contact-tracing (CT), and more.
|
|
30
|
+
Include canonical, fossilized birth-death, epidemiological, birth-death with exposed-infectious (BDEI), birth-death with superspreading (BDSS), contact-tracing (CT), and more.
|
|
31
31
|
|
|
32
32
|
- **Skyline parameter support** 🪜
|
|
33
33
|
Support for piece-wise constant parameters.
|
|
@@ -17,15 +17,16 @@ from phylogenie.skyline import (
|
|
|
17
17
|
DEFAULT_POPULATION = "X"
|
|
18
18
|
INFECTIOUS_POPULATION = "I"
|
|
19
19
|
EXPOSED_POPULATION = "E"
|
|
20
|
+
SUPERSPREADER_POPULATION = "S"
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
@dataclass
|
|
23
24
|
class TreeParams:
|
|
24
|
-
populations: str | list[str]
|
|
25
|
+
populations: str | list[str]
|
|
26
|
+
transmission_rates: SkylineMatrixCoercible
|
|
27
|
+
removal_rates: SkylineVectorCoercible
|
|
28
|
+
sampling_proportions: SkylineVectorCoercible
|
|
25
29
|
transition_rates: SkylineMatrixCoercible = 0
|
|
26
|
-
transmission_rates: SkylineMatrixCoercible = 0
|
|
27
|
-
removal_rates: SkylineVectorCoercible = 0
|
|
28
|
-
sampling_proportions: SkylineVectorCoercible = 0
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
def generate_tree(
|
|
@@ -100,6 +101,7 @@ def generate_tree(
|
|
|
100
101
|
)
|
|
101
102
|
for i, leaf in enumerate(tree.iter_leaves()):
|
|
102
103
|
state: str = getattr(leaf, STATE)
|
|
104
|
+
delattr(leaf, STATE)
|
|
103
105
|
date = tree.get_distance(leaf)
|
|
104
106
|
leaf.name = f"{i}|{state}|{date}"
|
|
105
107
|
save_forest([tree], output_file)
|
|
@@ -137,3 +139,25 @@ def get_BDEI_params(
|
|
|
137
139
|
removal_rates=removal_rates,
|
|
138
140
|
sampling_proportions=sampling_proportions,
|
|
139
141
|
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def get_BDSS_params(
|
|
145
|
+
reproduction_number: SkylineParameterLike,
|
|
146
|
+
infectious_period: SkylineParameterLike,
|
|
147
|
+
superspreading_ratio: SkylineParameterLike,
|
|
148
|
+
superspreaders_proportion: SkylineParameterLike,
|
|
149
|
+
sampling_proportion: SkylineParameterLike,
|
|
150
|
+
) -> TreeParams:
|
|
151
|
+
gamma = 1 / infectious_period
|
|
152
|
+
f_SS = superspreaders_proportion
|
|
153
|
+
r_SS = superspreading_ratio
|
|
154
|
+
lambda_IS = reproduction_number * gamma * f_SS / (1 + r_SS * f_SS - f_SS)
|
|
155
|
+
lambda_SI = (reproduction_number * gamma - r_SS * lambda_IS) * r_SS
|
|
156
|
+
lambda_SS = r_SS * lambda_IS
|
|
157
|
+
lambda_II = lambda_SI / r_SS
|
|
158
|
+
return TreeParams(
|
|
159
|
+
populations=[INFECTIOUS_POPULATION, SUPERSPREADER_POPULATION],
|
|
160
|
+
transmission_rates=[[lambda_II, lambda_IS], [lambda_SI, lambda_SS]],
|
|
161
|
+
removal_rates=gamma,
|
|
162
|
+
sampling_proportions=sampling_proportion,
|
|
163
|
+
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from abc import abstractmethod
|
|
3
3
|
from enum import Enum
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
from typing import Literal
|
|
5
6
|
|
|
6
7
|
from numpy.random import Generator
|
|
@@ -14,9 +15,14 @@ class BackendType(str, Enum):
|
|
|
14
15
|
ALISIM = "alisim"
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
MSAS_DIRNAME = "MSAs"
|
|
19
|
+
TREES_DIRNAME = "trees"
|
|
20
|
+
|
|
21
|
+
|
|
17
22
|
class MSAsGenerator(DatasetGenerator):
|
|
18
23
|
data_type: Literal[DataType.MSAS] = DataType.MSAS
|
|
19
24
|
trees: TreesGeneratorConfig
|
|
25
|
+
keep_trees: bool = False
|
|
20
26
|
|
|
21
27
|
@abstractmethod
|
|
22
28
|
def _generate_one_from_tree(
|
|
@@ -24,11 +30,22 @@ class MSAsGenerator(DatasetGenerator):
|
|
|
24
30
|
) -> None: ...
|
|
25
31
|
|
|
26
32
|
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
27
|
-
|
|
33
|
+
if self.keep_trees:
|
|
34
|
+
base_dir = Path(filename).parent
|
|
35
|
+
file_id = Path(filename).stem
|
|
36
|
+
tree_filename = os.path.join(base_dir, TREES_DIRNAME, file_id)
|
|
37
|
+
msas_dir = os.path.join(base_dir, MSAS_DIRNAME)
|
|
38
|
+
os.makedirs(msas_dir, exist_ok=True)
|
|
39
|
+
msa_filename = os.path.join(msas_dir, file_id)
|
|
40
|
+
else:
|
|
41
|
+
tree_filename = f"{filename}.temp-tree"
|
|
42
|
+
msa_filename = filename
|
|
43
|
+
|
|
28
44
|
self.trees.generate_one(
|
|
29
45
|
filename=tree_filename, data=data, seed=int(rng.integers(0, 2**32 - 1))
|
|
30
46
|
)
|
|
31
47
|
self._generate_one_from_tree(
|
|
32
|
-
filename=
|
|
48
|
+
filename=msa_filename, tree_file=f"{tree_filename}.nwk", rng=rng, data=data
|
|
33
49
|
)
|
|
34
|
-
|
|
50
|
+
if not self.keep_trees:
|
|
51
|
+
os.remove(f"{tree_filename}.nwk")
|
|
@@ -13,6 +13,7 @@ from phylogenie.backend.treesimulator import (
|
|
|
13
13
|
generate_tree,
|
|
14
14
|
get_BD_params,
|
|
15
15
|
get_BDEI_params,
|
|
16
|
+
get_BDSS_params,
|
|
16
17
|
)
|
|
17
18
|
from phylogenie.core.factories import (
|
|
18
19
|
int_factory,
|
|
@@ -28,6 +29,7 @@ class ParameterizationType(str, Enum):
|
|
|
28
29
|
MTBD = "MTBD"
|
|
29
30
|
BD = "BD"
|
|
30
31
|
BDEI = "BDEI"
|
|
32
|
+
BDSS = "BDSS"
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
class TreeSimulatorGenerator(TreesGenerator):
|
|
@@ -73,10 +75,10 @@ class TreeSimulatorGenerator(TreesGenerator):
|
|
|
73
75
|
class MTBDTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
74
76
|
parameterization: Literal[ParameterizationType.MTBD] = ParameterizationType.MTBD
|
|
75
77
|
populations: str | list[str] = DEFAULT_POPULATION
|
|
78
|
+
transmission_rates: cfg.SkylineMatrixCoercibleConfig
|
|
79
|
+
removal_rates: cfg.SkylineVectorCoercibleConfig
|
|
76
80
|
transition_rates: cfg.SkylineMatrixCoercibleConfig = 0
|
|
77
|
-
|
|
78
|
-
removal_rates: cfg.SkylineVectorCoercibleConfig = 0
|
|
79
|
-
sampling_proportions: cfg.SkylineVectorCoercibleConfig = 0
|
|
81
|
+
sampling_proportions: cfg.SkylineVectorCoercibleConfig = 1
|
|
80
82
|
|
|
81
83
|
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
82
84
|
self._generate_one_from_params(
|
|
@@ -103,9 +105,9 @@ class MTBDTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
|
103
105
|
|
|
104
106
|
class BDTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
105
107
|
parameterization: Literal[ParameterizationType.BD] = ParameterizationType.BD
|
|
106
|
-
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
107
|
-
infectious_period: cfg.SkylineParameterLikeConfig
|
|
108
|
-
sampling_proportion: cfg.SkylineParameterLikeConfig =
|
|
108
|
+
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
109
|
+
infectious_period: cfg.SkylineParameterLikeConfig
|
|
110
|
+
sampling_proportion: cfg.SkylineParameterLikeConfig = 1
|
|
109
111
|
|
|
110
112
|
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
111
113
|
self._generate_one_from_params(
|
|
@@ -128,10 +130,10 @@ class BDTreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
|
128
130
|
|
|
129
131
|
class BDEITreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
130
132
|
parameterization: Literal[ParameterizationType.BDEI] = ParameterizationType.BDEI
|
|
131
|
-
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
132
|
-
infectious_period: cfg.SkylineParameterLikeConfig
|
|
133
|
-
incubation_period: cfg.SkylineParameterLikeConfig
|
|
134
|
-
sampling_proportion: cfg.SkylineParameterLikeConfig =
|
|
133
|
+
reproduction_number: cfg.SkylineParameterLikeConfig
|
|
134
|
+
infectious_period: cfg.SkylineParameterLikeConfig
|
|
135
|
+
incubation_period: cfg.SkylineParameterLikeConfig
|
|
136
|
+
sampling_proportion: cfg.SkylineParameterLikeConfig = 1
|
|
135
137
|
|
|
136
138
|
def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
|
|
137
139
|
self._generate_one_from_params(
|
|
@@ -155,7 +157,43 @@ class BDEITreeSimulatorGenerator(TreeSimulatorGenerator):
|
|
|
155
157
|
)
|
|
156
158
|
|
|
157
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
|
+
|
|
158
193
|
TreeSimulatorGeneratorConfig = Annotated[
|
|
159
|
-
MTBDTreeSimulatorGenerator
|
|
194
|
+
MTBDTreeSimulatorGenerator
|
|
195
|
+
| BDTreeSimulatorGenerator
|
|
196
|
+
| BDEITreeSimulatorGenerator
|
|
197
|
+
| BDSSTreeSimulatorGenerator,
|
|
160
198
|
Field(discriminator="parameterization"),
|
|
161
199
|
]
|
|
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
|
|
File without changes
|
|
File without changes
|