phylogenie 2.0.8__py3-none-any.whl → 2.0.10__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/configs.py +10 -3
- phylogenie/generators/dataset.py +8 -6
- phylogenie/generators/factories.py +6 -1
- phylogenie/treesimulator/gillespie.py +3 -2
- {phylogenie-2.0.8.dist-info → phylogenie-2.0.10.dist-info}/METADATA +1 -1
- {phylogenie-2.0.8.dist-info → phylogenie-2.0.10.dist-info}/RECORD +9 -9
- {phylogenie-2.0.8.dist-info → phylogenie-2.0.10.dist-info}/LICENSE.txt +0 -0
- {phylogenie-2.0.8.dist-info → phylogenie-2.0.10.dist-info}/WHEEL +0 -0
- {phylogenie-2.0.8.dist-info → phylogenie-2.0.10.dist-info}/entry_points.txt +0 -0
phylogenie/generators/configs.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
from pydantic import BaseModel, ConfigDict
|
|
2
2
|
|
|
3
3
|
import phylogenie.typings as pgt
|
|
4
|
+
from phylogenie.skyline import SkylineMatrix as _SkylineMatrix
|
|
5
|
+
from phylogenie.skyline import SkylineParameter as _SkylineParameter
|
|
6
|
+
from phylogenie.skyline import SkylineVector as _SkylineVector
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
class Distribution(BaseModel):
|
|
@@ -34,6 +37,10 @@ class SkylineMatrixModel(StrictBaseModel):
|
|
|
34
37
|
change_times: ManyScalars
|
|
35
38
|
|
|
36
39
|
|
|
37
|
-
SkylineParameter = Scalar | SkylineParameterModel
|
|
38
|
-
SkylineVector =
|
|
39
|
-
|
|
40
|
+
SkylineParameter = Scalar | SkylineParameterModel | _SkylineParameter
|
|
41
|
+
SkylineVector = (
|
|
42
|
+
str | pgt.Scalar | list[SkylineParameter] | SkylineVectorModel | _SkylineVector
|
|
43
|
+
)
|
|
44
|
+
SkylineMatrix = (
|
|
45
|
+
str | pgt.Scalar | list[SkylineVector] | SkylineMatrixModel | None | _SkylineMatrix
|
|
46
|
+
)
|
phylogenie/generators/dataset.py
CHANGED
|
@@ -41,19 +41,21 @@ class DatasetGenerator(ABC, cfg.StrictBaseModel):
|
|
|
41
41
|
self._generate_one(filename=filename, rng=default_rng(seed), data=data)
|
|
42
42
|
|
|
43
43
|
def _generate(self, rng: Generator, n_samples: int, output_dir: str) -> None:
|
|
44
|
-
data_dir = os.path.join(output_dir, DATA_DIRNAME)
|
|
45
|
-
if os.path.exists(data_dir):
|
|
46
|
-
print(f"Output directory {data_dir} already exists. Skipping.")
|
|
47
|
-
return
|
|
48
|
-
os.makedirs(data_dir)
|
|
49
|
-
|
|
50
44
|
data: list[dict[str, Any]] = [{} for _ in range(n_samples)]
|
|
51
45
|
if self.context is not None:
|
|
46
|
+
data_dir = os.path.join(output_dir, DATA_DIRNAME)
|
|
52
47
|
for d, (k, v) in product(data, self.context.items()):
|
|
53
48
|
args = v.model_extra if v.model_extra is not None else {}
|
|
54
49
|
d[k] = np.array(getattr(rng, v.type)(**args)).tolist()
|
|
55
50
|
df = pd.DataFrame([{"file_id": str(i), **d} for i, d in enumerate(data)])
|
|
56
51
|
df.to_csv(os.path.join(output_dir, METADATA_FILENAME), index=False)
|
|
52
|
+
else:
|
|
53
|
+
data_dir = output_dir
|
|
54
|
+
|
|
55
|
+
if os.path.exists(data_dir):
|
|
56
|
+
print(f"Output directory {data_dir} already exists. Skipping.")
|
|
57
|
+
return
|
|
58
|
+
os.makedirs(data_dir)
|
|
57
59
|
|
|
58
60
|
joblib.Parallel(n_jobs=self.n_jobs)(
|
|
59
61
|
joblib.delayed(self.generate_one)(
|
|
@@ -80,6 +80,8 @@ def one_or_many_scalars(
|
|
|
80
80
|
def skyline_parameter(
|
|
81
81
|
x: cfg.SkylineParameter, data: dict[str, Any]
|
|
82
82
|
) -> SkylineParameterLike:
|
|
83
|
+
if isinstance(x, SkylineParameter):
|
|
84
|
+
return x
|
|
83
85
|
if isinstance(x, cfg.Scalar):
|
|
84
86
|
return scalar(x, data)
|
|
85
87
|
return SkylineParameter(
|
|
@@ -91,6 +93,8 @@ def skyline_parameter(
|
|
|
91
93
|
def skyline_vector(
|
|
92
94
|
x: cfg.SkylineVector, data: dict[str, Any]
|
|
93
95
|
) -> SkylineVectorCoercible:
|
|
96
|
+
if isinstance(x, SkylineVector):
|
|
97
|
+
return x
|
|
94
98
|
if isinstance(x, str):
|
|
95
99
|
e = _eval_expression(x, data)
|
|
96
100
|
if tg.is_one_or_many_scalars(e):
|
|
@@ -151,7 +155,8 @@ def skyline_matrix(
|
|
|
151
155
|
) -> SkylineMatrixCoercible | None:
|
|
152
156
|
if x is None:
|
|
153
157
|
return None
|
|
154
|
-
|
|
158
|
+
if isinstance(x, SkylineMatrix):
|
|
159
|
+
return x
|
|
155
160
|
if isinstance(x, str):
|
|
156
161
|
e = _eval_expression(x, data)
|
|
157
162
|
if tg.is_one_or_many_2D_scalars(e):
|
|
@@ -6,7 +6,7 @@ from numpy.random import default_rng
|
|
|
6
6
|
from phylogenie.skyline import SkylineParameterLike
|
|
7
7
|
from phylogenie.tree import Tree
|
|
8
8
|
from phylogenie.treesimulator.events import Event, get_contact_tracing_events
|
|
9
|
-
from phylogenie.treesimulator.model import Model
|
|
9
|
+
from phylogenie.treesimulator.model import Model
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def simulate_tree(
|
|
@@ -29,6 +29,8 @@ def simulate_tree(
|
|
|
29
29
|
if max_tips is None and max_time == np.inf:
|
|
30
30
|
raise ValueError("Either max_tips or max_time must be specified.")
|
|
31
31
|
|
|
32
|
+
root_states = list({e.state for e in events})
|
|
33
|
+
|
|
32
34
|
if notification_probability:
|
|
33
35
|
events = get_contact_tracing_events(
|
|
34
36
|
events,
|
|
@@ -38,7 +40,6 @@ def simulate_tree(
|
|
|
38
40
|
)
|
|
39
41
|
|
|
40
42
|
n_tries = 0
|
|
41
|
-
root_states = [e.state for e in events if not is_CT_state(e.state)]
|
|
42
43
|
while max_tries is None or n_tries < max_tries:
|
|
43
44
|
root_state = init_state if init_state is not None else rng.choice(root_states)
|
|
44
45
|
model = Model(root_state, max_notified_contacts, notification_probability, rng)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
phylogenie/__init__.py,sha256=1w_0H9lg7hI3b-NLjKuzc34GbJJGyjLq9LrlogecTzI,1759
|
|
2
2
|
phylogenie/generators/__init__.py,sha256=zsOxy28-9j9alOQLIgrOAFfmM58NNHO_NEtW-KXQXAY,888
|
|
3
3
|
phylogenie/generators/alisim.py,sha256=dDqlSwLDbRE2u5SZlsq1mArobTBtuk0aeXY3m1N-bWA,2374
|
|
4
|
-
phylogenie/generators/configs.py,sha256=
|
|
5
|
-
phylogenie/generators/dataset.py,sha256=
|
|
6
|
-
phylogenie/generators/factories.py,sha256=
|
|
4
|
+
phylogenie/generators/configs.py,sha256=DAwJbAJ-1ZUTEvhPE5zs58KsIOA88gcRtrqVx0zONi4,1234
|
|
5
|
+
phylogenie/generators/dataset.py,sha256=OB51YI9ilo-lrw8ETCDQAFh9iXWtPLBRyLg4JOjMi7c,2577
|
|
6
|
+
phylogenie/generators/factories.py,sha256=lXGlN8DXFZmFNN5WwTpE8J80jWj01Zx6MkAYHrAvlTs,7108
|
|
7
7
|
phylogenie/generators/trees.py,sha256=jukaVXGcPGzDBEYMGJ1MKqWt4XbAB5EEfuHXDpwKTqM,9173
|
|
8
8
|
phylogenie/generators/typeguards.py,sha256=Qph6ZnQ7wDMUNvB0VWQKlq42f8wkKOnM42cfMqhNov4,862
|
|
9
9
|
phylogenie/io.py,sha256=ZXlofnSh7FX5UJiP0svRHrTraMSNgKa1GiAv0bMz7jU,2854
|
|
@@ -17,12 +17,12 @@ phylogenie/skyline/vector.py,sha256=bJP7_FNX_Klt6wXqsyfj0KX3VNj6-dIhzCKSJuQcOV0,
|
|
|
17
17
|
phylogenie/tree.py,sha256=dk8Sj1tqyGOunVO2crtIqb0LH-ws-PXqA8SuNcYfVHI,1738
|
|
18
18
|
phylogenie/treesimulator/__init__.py,sha256=INPU9LrPdUmt3dYGzWDRoRKrPR9xENcHu44pJVUbyNA,525
|
|
19
19
|
phylogenie/treesimulator/events.py,sha256=X3_0U9qqMpYgh6-7TwQEnlUipANkHz6QTCXlm-qXFQk,9524
|
|
20
|
-
phylogenie/treesimulator/gillespie.py,sha256=
|
|
20
|
+
phylogenie/treesimulator/gillespie.py,sha256=4uMt_-Rr3cRXWGKC8veBIB-uqtKtN-dLbAHKjAi_5Mo,3182
|
|
21
21
|
phylogenie/treesimulator/model.py,sha256=XpzAicmg2O6K0Trk5YolH-B_HJZxoSauF2wZOMqp-Iw,5559
|
|
22
22
|
phylogenie/typeguards.py,sha256=JtqmbEWJZBRHbWgCvcl6nrWm3VcBfzRbklbTBYHItn0,1325
|
|
23
23
|
phylogenie/typings.py,sha256=O1X6lGKTjJ2YJz3ApQ-rYb_tEJNUIcHdUIeYlSM4s5o,500
|
|
24
|
-
phylogenie-2.0.
|
|
25
|
-
phylogenie-2.0.
|
|
26
|
-
phylogenie-2.0.
|
|
27
|
-
phylogenie-2.0.
|
|
28
|
-
phylogenie-2.0.
|
|
24
|
+
phylogenie-2.0.10.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
|
|
25
|
+
phylogenie-2.0.10.dist-info/METADATA,sha256=YQSy1_-Vkuan10JzF5IkKTxs4fWRbUzhMUDYfk143k8,5473
|
|
26
|
+
phylogenie-2.0.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
27
|
+
phylogenie-2.0.10.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
|
|
28
|
+
phylogenie-2.0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|