modelbase2 0.4.0__py3-none-any.whl → 0.6.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.
- modelbase2/experimental/codegen.py +1 -1
- modelbase2/experimental/tex.py +7 -9
- modelbase2/linear_label_map.py +4 -2
- modelbase2/model.py +200 -107
- modelbase2/plot.py +2 -2
- modelbase2/sbml/_import.py +16 -2
- modelbase2/scan.py +1 -1
- modelbase2/simulator.py +61 -33
- modelbase2/surrogates.py +2 -37
- modelbase2/types.py +126 -14
- {modelbase2-0.4.0.dist-info → modelbase2-0.6.0.dist-info}/METADATA +1 -1
- {modelbase2-0.4.0.dist-info → modelbase2-0.6.0.dist-info}/RECORD +14 -15
- modelbase2/experimental/_backup.py +0 -1017
- {modelbase2-0.4.0.dist-info → modelbase2-0.6.0.dist-info}/WHEEL +0 -0
- {modelbase2-0.4.0.dist-info → modelbase2-0.6.0.dist-info}/licenses/LICENSE +0 -0
modelbase2/simulator.py
CHANGED
@@ -69,7 +69,7 @@ class Simulator:
|
|
69
69
|
y0: Initial conditions for the simulation.
|
70
70
|
integrator: Integrator protocol to use for the simulation.
|
71
71
|
concs: List of DataFrames containing concentration results.
|
72
|
-
|
72
|
+
dependent: List of DataFrames containing argument values.
|
73
73
|
simulation_parameters: List of dictionaries containing simulation parameters.
|
74
74
|
|
75
75
|
"""
|
@@ -78,7 +78,7 @@ class Simulator:
|
|
78
78
|
y0: ArrayLike
|
79
79
|
integrator: IntegratorProtocol
|
80
80
|
concs: list[pd.DataFrame] | None
|
81
|
-
|
81
|
+
dependent: list[pd.DataFrame] | None
|
82
82
|
simulation_parameters: list[dict[str, float]] | None
|
83
83
|
|
84
84
|
def __init__(
|
@@ -110,13 +110,10 @@ class Simulator:
|
|
110
110
|
|
111
111
|
self.integrator = integrator(self.model, self.y0)
|
112
112
|
self.concs = None
|
113
|
-
self.args = None
|
114
113
|
self.simulation_parameters = None
|
115
114
|
|
116
115
|
if test_run:
|
117
116
|
y0 = dict(zip(model.get_variable_names(), self.y0, strict=True))
|
118
|
-
self.model.get_full_concs(y0, 0)
|
119
|
-
self.model.get_fluxes(y0, 0)
|
120
117
|
self.model.get_right_hand_side(y0, 0)
|
121
118
|
|
122
119
|
def _save_simulation_results(
|
@@ -146,7 +143,7 @@ class Simulator:
|
|
146
143
|
def clear_results(self) -> None:
|
147
144
|
"""Clear simulation results."""
|
148
145
|
self.concs = None
|
149
|
-
self.
|
146
|
+
self.dependent = None
|
150
147
|
self.simulation_parameters = None
|
151
148
|
if self.integrator is not None:
|
152
149
|
self.integrator.reset()
|
@@ -173,7 +170,7 @@ class Simulator:
|
|
173
170
|
return
|
174
171
|
|
175
172
|
# NOTE: IMPORTANT!
|
176
|
-
# model._get_rhs sorts the return array by model.
|
173
|
+
# model._get_rhs sorts the return array by model.get_variable_names()
|
177
174
|
# Do NOT change this ordering
|
178
175
|
results_df = pd.DataFrame(
|
179
176
|
results,
|
@@ -294,24 +291,24 @@ class Simulator:
|
|
294
291
|
break
|
295
292
|
return self
|
296
293
|
|
297
|
-
def
|
294
|
+
def _get_dependent_vectorised(
|
298
295
|
self,
|
299
296
|
concs: list[pd.DataFrame],
|
300
297
|
params: list[dict[str, float]],
|
301
298
|
*,
|
302
299
|
include_readouts: bool = True,
|
303
300
|
) -> list[pd.DataFrame]:
|
304
|
-
|
301
|
+
dependent: list[pd.DataFrame] = []
|
305
302
|
|
306
303
|
for res, p in zip(concs, params, strict=True):
|
307
304
|
self.model.update_parameters(p)
|
308
|
-
|
309
|
-
self.model.
|
305
|
+
dependent.append(
|
306
|
+
self.model.get_dependent_time_course(
|
310
307
|
concs=res,
|
311
308
|
include_readouts=include_readouts,
|
312
309
|
)
|
313
310
|
)
|
314
|
-
return
|
311
|
+
return dependent
|
315
312
|
|
316
313
|
@overload
|
317
314
|
def get_concs( # type: ignore
|
@@ -367,6 +364,16 @@ class Simulator:
|
|
367
364
|
|
368
365
|
return results
|
369
366
|
|
367
|
+
# Get results depending on the raw results
|
368
|
+
|
369
|
+
def _get_dependent(self) -> list[pd.DataFrame] | None:
|
370
|
+
if (concs := self.concs) is None:
|
371
|
+
return None
|
372
|
+
if (params := self.simulation_parameters) is None:
|
373
|
+
return None
|
374
|
+
|
375
|
+
return self._get_dependent_vectorised(concs, params)
|
376
|
+
|
370
377
|
@overload
|
371
378
|
def get_full_concs( # type: ignore
|
372
379
|
self,
|
@@ -374,6 +381,7 @@ class Simulator:
|
|
374
381
|
normalise: float | ArrayLike | None = None,
|
375
382
|
concatenated: Literal[False],
|
376
383
|
include_readouts: bool = True,
|
384
|
+
dependent: list[pd.DataFrame] | None = None,
|
377
385
|
) -> list[pd.DataFrame] | None: ...
|
378
386
|
|
379
387
|
@overload
|
@@ -383,6 +391,7 @@ class Simulator:
|
|
383
391
|
normalise: float | ArrayLike | None = None,
|
384
392
|
concatenated: Literal[True],
|
385
393
|
include_readouts: bool = True,
|
394
|
+
dependent: list[pd.DataFrame] | None = None,
|
386
395
|
) -> pd.DataFrame | None: ...
|
387
396
|
|
388
397
|
@overload
|
@@ -392,6 +401,7 @@ class Simulator:
|
|
392
401
|
normalise: float | ArrayLike | None = None,
|
393
402
|
concatenated: bool = True,
|
394
403
|
include_readouts: bool = True,
|
404
|
+
dependent: list[pd.DataFrame] | None = None,
|
395
405
|
) -> pd.DataFrame | None: ...
|
396
406
|
|
397
407
|
def get_full_concs(
|
@@ -400,6 +410,7 @@ class Simulator:
|
|
400
410
|
normalise: float | ArrayLike | None = None,
|
401
411
|
concatenated: bool = True,
|
402
412
|
include_readouts: bool = True,
|
413
|
+
dependent: list[pd.DataFrame] | None = None,
|
403
414
|
) -> pd.DataFrame | list[pd.DataFrame] | None:
|
404
415
|
"""Get the full concentration results, including derived quantities.
|
405
416
|
|
@@ -417,23 +428,25 @@ class Simulator:
|
|
417
428
|
return None
|
418
429
|
if (params := self.simulation_parameters) is None:
|
419
430
|
return None
|
420
|
-
if
|
421
|
-
|
431
|
+
if dependent is None:
|
432
|
+
dependent = self._get_dependent_vectorised(concs, params)
|
422
433
|
|
434
|
+
# Filter to full concs
|
423
435
|
names = (
|
424
436
|
self.model.get_variable_names() + self.model.get_derived_variable_names()
|
425
437
|
)
|
426
438
|
if include_readouts:
|
427
439
|
names.extend(self.model.get_readout_names())
|
428
|
-
|
440
|
+
dependent = [i.loc[:, names] for i in dependent]
|
441
|
+
|
429
442
|
if normalise is not None:
|
430
|
-
|
431
|
-
results=
|
443
|
+
dependent = _normalise_split_results(
|
444
|
+
results=dependent,
|
432
445
|
normalise=normalise,
|
433
446
|
)
|
434
447
|
if concatenated:
|
435
|
-
return pd.concat(
|
436
|
-
return
|
448
|
+
return pd.concat(dependent, axis=0)
|
449
|
+
return dependent
|
437
450
|
|
438
451
|
@overload
|
439
452
|
def get_fluxes( # type: ignore
|
@@ -441,6 +454,7 @@ class Simulator:
|
|
441
454
|
*,
|
442
455
|
normalise: float | ArrayLike | None = None,
|
443
456
|
concatenated: Literal[False],
|
457
|
+
dependent: list[pd.DataFrame] | None = None,
|
444
458
|
) -> list[pd.DataFrame] | None: ...
|
445
459
|
|
446
460
|
@overload
|
@@ -449,6 +463,7 @@ class Simulator:
|
|
449
463
|
*,
|
450
464
|
normalise: float | ArrayLike | None = None,
|
451
465
|
concatenated: Literal[True],
|
466
|
+
dependent: list[pd.DataFrame] | None = None,
|
452
467
|
) -> pd.DataFrame | None: ...
|
453
468
|
|
454
469
|
@overload
|
@@ -457,6 +472,7 @@ class Simulator:
|
|
457
472
|
*,
|
458
473
|
normalise: float | ArrayLike | None = None,
|
459
474
|
concatenated: bool = True,
|
475
|
+
dependent: list[pd.DataFrame] | None = None,
|
460
476
|
) -> pd.DataFrame | None: ...
|
461
477
|
|
462
478
|
def get_fluxes(
|
@@ -464,6 +480,7 @@ class Simulator:
|
|
464
480
|
*,
|
465
481
|
normalise: float | ArrayLike | None = None,
|
466
482
|
concatenated: bool = True,
|
483
|
+
dependent: list[pd.DataFrame] | None = None,
|
467
484
|
) -> pd.DataFrame | list[pd.DataFrame] | None:
|
468
485
|
"""Get the flux results.
|
469
486
|
|
@@ -482,22 +499,20 @@ class Simulator:
|
|
482
499
|
return None
|
483
500
|
if (params := self.simulation_parameters) is None:
|
484
501
|
return None
|
485
|
-
if
|
486
|
-
|
487
|
-
|
488
|
-
fluxes: list[pd.DataFrame] = []
|
489
|
-
for y, p in zip(args, params, strict=True):
|
490
|
-
self.model.update_parameters(p)
|
491
|
-
fluxes.append(self.model.get_fluxes_time_course(args=y))
|
502
|
+
if dependent is None:
|
503
|
+
dependent = self._get_dependent_vectorised(concs, params)
|
492
504
|
|
505
|
+
# Filter to fluxes
|
506
|
+
names = self.model.get_reaction_names()
|
507
|
+
dependent = [i.loc[:, names] for i in dependent]
|
493
508
|
if normalise is not None:
|
494
|
-
|
495
|
-
results=
|
509
|
+
dependent = _normalise_split_results(
|
510
|
+
results=dependent,
|
496
511
|
normalise=normalise,
|
497
512
|
)
|
498
513
|
if concatenated:
|
499
|
-
return pd.concat(
|
500
|
-
return
|
514
|
+
return pd.concat(dependent, axis=0)
|
515
|
+
return dependent
|
501
516
|
|
502
517
|
def get_concs_and_fluxes(self) -> tuple[pd.DataFrame | None, pd.DataFrame | None]:
|
503
518
|
"""Get the concentrations and fluxes.
|
@@ -511,7 +526,14 @@ class Simulator:
|
|
511
526
|
tuple[pd.DataFrame, pd.DataFrame]: Tuple of concentrations and fluxes.
|
512
527
|
|
513
528
|
"""
|
514
|
-
|
529
|
+
if (concs := self.concs) is None:
|
530
|
+
return None, None
|
531
|
+
if (params := self.simulation_parameters) is None:
|
532
|
+
return None, None
|
533
|
+
|
534
|
+
dependent = self._get_dependent_vectorised(concs, params)
|
535
|
+
|
536
|
+
return self.get_concs(), self.get_fluxes(dependent=dependent)
|
515
537
|
|
516
538
|
def get_full_concs_and_fluxes(
|
517
539
|
self,
|
@@ -530,9 +552,15 @@ class Simulator:
|
|
530
552
|
Full concentrations and fluxes
|
531
553
|
|
532
554
|
"""
|
555
|
+
if (concs := self.concs) is None:
|
556
|
+
return None, None
|
557
|
+
if (params := self.simulation_parameters) is None:
|
558
|
+
return None, None
|
559
|
+
dependent = self._get_dependent_vectorised(concs, params)
|
560
|
+
|
533
561
|
return (
|
534
|
-
self.get_full_concs(include_readouts=include_readouts),
|
535
|
-
self.get_fluxes(),
|
562
|
+
self.get_full_concs(include_readouts=include_readouts, dependent=dependent),
|
563
|
+
self.get_fluxes(dependent=dependent),
|
536
564
|
)
|
537
565
|
|
538
566
|
def get_results(self) -> pd.DataFrame | None:
|
modelbase2/surrogates.py
CHANGED
@@ -16,7 +16,6 @@ Functions:
|
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
|
-
from abc import abstractmethod
|
20
19
|
from dataclasses import dataclass
|
21
20
|
from pathlib import Path
|
22
21
|
from typing import TYPE_CHECKING
|
@@ -29,6 +28,7 @@ from torch import nn
|
|
29
28
|
from torch.optim.adam import Adam
|
30
29
|
|
31
30
|
from modelbase2.parallel import Cache
|
31
|
+
from modelbase2.types import AbstractSurrogate
|
32
32
|
|
33
33
|
if TYPE_CHECKING:
|
34
34
|
from collections.abc import Callable
|
@@ -36,11 +36,9 @@ if TYPE_CHECKING:
|
|
36
36
|
from torch.optim.optimizer import ParamsT
|
37
37
|
|
38
38
|
__all__ = [
|
39
|
-
"AbstractSurrogate",
|
40
39
|
"Approximator",
|
41
40
|
"DefaultCache",
|
42
41
|
"DefaultDevice",
|
43
|
-
"MockSurrogate",
|
44
42
|
"TorchSurrogate",
|
45
43
|
"train_torch_surrogate",
|
46
44
|
]
|
@@ -50,39 +48,6 @@ DefaultDevice = torch.device("cpu")
|
|
50
48
|
DefaultCache = Cache(Path(".cache"))
|
51
49
|
|
52
50
|
|
53
|
-
@dataclass(kw_only=True)
|
54
|
-
class AbstractSurrogate:
|
55
|
-
"""Abstract base class for surrogate models.
|
56
|
-
|
57
|
-
Attributes:
|
58
|
-
inputs: List of input variable names.
|
59
|
-
stoichiometries: Dictionary mapping reaction names to stoichiometries.
|
60
|
-
|
61
|
-
Methods:
|
62
|
-
predict: Abstract method to predict outputs based on input data.
|
63
|
-
|
64
|
-
"""
|
65
|
-
|
66
|
-
inputs: list[str]
|
67
|
-
stoichiometries: dict[str, dict[str, float]]
|
68
|
-
|
69
|
-
@abstractmethod
|
70
|
-
def predict(self, y: np.ndarray) -> dict[str, float]:
|
71
|
-
"""Predict outputs based on input data."""
|
72
|
-
|
73
|
-
|
74
|
-
@dataclass(kw_only=True)
|
75
|
-
class MockSurrogate(AbstractSurrogate):
|
76
|
-
"""Mock surrogate model for testing purposes."""
|
77
|
-
|
78
|
-
def predict(
|
79
|
-
self,
|
80
|
-
y: np.ndarray,
|
81
|
-
) -> dict[str, float]:
|
82
|
-
"""Predict outputs based on input data."""
|
83
|
-
return dict(zip(self.stoichiometries, y, strict=True))
|
84
|
-
|
85
|
-
|
86
51
|
@dataclass(kw_only=True)
|
87
52
|
class TorchSurrogate(AbstractSurrogate):
|
88
53
|
"""Surrogate model using PyTorch.
|
@@ -316,7 +281,7 @@ def train_torch_surrogate(
|
|
316
281
|
)
|
317
282
|
surrogate = TorchSurrogate(
|
318
283
|
model=approximator,
|
319
|
-
|
284
|
+
args=surrogate_inputs,
|
320
285
|
stoichiometries=surrogate_stoichiometries,
|
321
286
|
)
|
322
287
|
return surrogate, losses
|
modelbase2/types.py
CHANGED
@@ -147,31 +147,96 @@ class IntegratorProtocol(Protocol):
|
|
147
147
|
...
|
148
148
|
|
149
149
|
|
150
|
-
@dataclass(slots=True)
|
150
|
+
@dataclass(kw_only=True, slots=True)
|
151
151
|
class Derived:
|
152
152
|
"""Container for a derived value."""
|
153
153
|
|
154
|
+
name: str
|
154
155
|
fn: RateFn
|
155
156
|
args: list[str]
|
156
|
-
math: str | None = None
|
157
157
|
|
158
|
+
def calculate(self, dependent: dict[str, float]) -> float:
|
159
|
+
"""Calculate the derived value.
|
158
160
|
|
159
|
-
|
161
|
+
Args:
|
162
|
+
dependent: Dictionary of dependent variables.
|
163
|
+
|
164
|
+
Returns:
|
165
|
+
The calculated derived value.
|
166
|
+
|
167
|
+
"""
|
168
|
+
return cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
169
|
+
|
170
|
+
def calculate_inpl(self, dependent: dict[str, float]) -> None:
|
171
|
+
"""Calculate the derived value in place.
|
172
|
+
|
173
|
+
Args:
|
174
|
+
dependent: Dictionary of dependent variables.
|
175
|
+
|
176
|
+
"""
|
177
|
+
dependent[self.name] = cast(
|
178
|
+
float, self.fn(*(dependent[arg] for arg in self.args))
|
179
|
+
)
|
180
|
+
|
181
|
+
def calculate_inpl_time_course(self, dependent: pd.DataFrame) -> None:
|
182
|
+
"""Calculate the derived value in place.
|
183
|
+
|
184
|
+
Args:
|
185
|
+
dependent: Dictionary of dependent variables.
|
186
|
+
|
187
|
+
"""
|
188
|
+
dependent[self.name] = self.fn(*dependent.loc[:, self.args].to_numpy().T)
|
189
|
+
|
190
|
+
|
191
|
+
@dataclass(kw_only=True, slots=True)
|
160
192
|
class Readout:
|
161
193
|
"""Container for a readout."""
|
162
194
|
|
195
|
+
name: str
|
163
196
|
fn: RateFn
|
164
197
|
args: list[str]
|
165
198
|
|
199
|
+
def calculate(self, dependent: dict[str, float]) -> float:
|
200
|
+
"""Calculate the derived value.
|
201
|
+
|
202
|
+
Args:
|
203
|
+
dependent: Dictionary of dependent variables.
|
204
|
+
|
205
|
+
Returns:
|
206
|
+
The calculated derived value.
|
207
|
+
|
208
|
+
"""
|
209
|
+
return cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
210
|
+
|
211
|
+
def calculate_inpl(self, dependent: dict[str, float]) -> None:
|
212
|
+
"""Calculate the readout in place.
|
213
|
+
|
214
|
+
Args:
|
215
|
+
dependent: Dictionary of dependent variables.
|
216
|
+
|
217
|
+
"""
|
218
|
+
dependent[self.name] = cast(
|
219
|
+
float, self.fn(*(dependent[arg] for arg in self.args))
|
220
|
+
)
|
221
|
+
|
222
|
+
def calculate_inpl_time_course(self, dependent: pd.DataFrame) -> None:
|
223
|
+
"""Calculate the derived value in place.
|
166
224
|
|
167
|
-
|
225
|
+
Args:
|
226
|
+
dependent: Dictionary of dependent variables.
|
227
|
+
|
228
|
+
"""
|
229
|
+
dependent[self.name] = self.fn(*dependent.loc[:, self.args].to_numpy().T)
|
230
|
+
|
231
|
+
|
232
|
+
@dataclass(kw_only=True, slots=True)
|
168
233
|
class Reaction:
|
169
234
|
"""Container for a reaction."""
|
170
235
|
|
236
|
+
name: str
|
171
237
|
fn: RateFn
|
172
238
|
stoichiometry: Mapping[str, float | Derived]
|
173
239
|
args: list[str]
|
174
|
-
math: str | None = None
|
175
240
|
|
176
241
|
def get_modifiers(self, model: Model) -> list[str]:
|
177
242
|
"""Get the modifiers of the reaction."""
|
@@ -180,8 +245,44 @@ class Reaction:
|
|
180
245
|
|
181
246
|
return [k for k in self.args if k in include and k not in exclude]
|
182
247
|
|
248
|
+
def calculate(self, dependent: dict[str, float]) -> float:
|
249
|
+
"""Calculate the derived value.
|
250
|
+
|
251
|
+
Args:
|
252
|
+
dependent: Dictionary of dependent variables.
|
253
|
+
|
254
|
+
Returns:
|
255
|
+
The calculated derived value.
|
256
|
+
|
257
|
+
"""
|
258
|
+
return cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
259
|
+
|
260
|
+
def calculate_inpl(self, dependent: dict[str, float]) -> None:
|
261
|
+
"""Calculate the reaction in place.
|
262
|
+
|
263
|
+
Args:
|
264
|
+
dependent: Dictionary of dependent variables.
|
265
|
+
|
266
|
+
"""
|
267
|
+
dependent[self.name] = cast(
|
268
|
+
float, self.fn(*(dependent[arg] for arg in self.args))
|
269
|
+
)
|
270
|
+
|
271
|
+
def calculate_inpl_time_course(self, dependent: pd.DataFrame) -> None:
|
272
|
+
"""Calculate the derived value in place.
|
273
|
+
|
274
|
+
Args:
|
275
|
+
dependent: Dictionary of dependent variables.
|
276
|
+
|
277
|
+
"""
|
278
|
+
try:
|
279
|
+
dependent[self.name] = self.fn(*dependent.loc[:, self.args].to_numpy().T)
|
280
|
+
except ValueError: # e.g. numpy.where
|
281
|
+
sub = dependent.loc[:, self.args].to_numpy()
|
282
|
+
dependent[self.name] = [self.fn(*row) for row in sub]
|
283
|
+
|
183
284
|
|
184
|
-
@dataclass(slots=True)
|
285
|
+
@dataclass(kw_only=True, slots=True)
|
185
286
|
class ResponseCoefficients:
|
186
287
|
"""Container for response coefficients."""
|
187
288
|
|
@@ -198,7 +299,7 @@ class ResponseCoefficients:
|
|
198
299
|
return pd.concat((self.concs, self.fluxes), axis=1)
|
199
300
|
|
200
301
|
|
201
|
-
@dataclass(slots=True)
|
302
|
+
@dataclass(kw_only=True, slots=True)
|
202
303
|
class ResponseCoefficientsByPars:
|
203
304
|
"""Container for response coefficients by parameter."""
|
204
305
|
|
@@ -216,7 +317,7 @@ class ResponseCoefficientsByPars:
|
|
216
317
|
return pd.concat((self.concs, self.fluxes), axis=1)
|
217
318
|
|
218
319
|
|
219
|
-
@dataclass(slots=True)
|
320
|
+
@dataclass(kw_only=True, slots=True)
|
220
321
|
class SteadyStates:
|
221
322
|
"""Container for steady states."""
|
222
323
|
|
@@ -234,7 +335,7 @@ class SteadyStates:
|
|
234
335
|
return pd.concat((self.concs, self.fluxes), axis=1)
|
235
336
|
|
236
337
|
|
237
|
-
@dataclass(slots=True)
|
338
|
+
@dataclass(kw_only=True, slots=True)
|
238
339
|
class McSteadyStates:
|
239
340
|
"""Container for Monte Carlo steady states."""
|
240
341
|
|
@@ -253,7 +354,7 @@ class McSteadyStates:
|
|
253
354
|
return pd.concat((self.concs, self.fluxes), axis=1)
|
254
355
|
|
255
356
|
|
256
|
-
@dataclass(slots=True)
|
357
|
+
@dataclass(kw_only=True, slots=True)
|
257
358
|
class TimeCourseByPars:
|
258
359
|
"""Container for time courses by parameter."""
|
259
360
|
|
@@ -285,7 +386,7 @@ class TimeCourseByPars:
|
|
285
386
|
return cast(pd.DataFrame, mean.unstack().T)
|
286
387
|
|
287
388
|
|
288
|
-
@dataclass(slots=True)
|
389
|
+
@dataclass(kw_only=True, slots=True)
|
289
390
|
class ProtocolByPars:
|
290
391
|
"""Container for protocols by parameter."""
|
291
392
|
|
@@ -348,14 +449,25 @@ class AbstractSurrogate:
|
|
348
449
|
)
|
349
450
|
)
|
350
451
|
|
452
|
+
def calculate_inpl(self, args: dict[str, float]) -> None:
|
453
|
+
"""Predict outputs based on input data."""
|
454
|
+
args |= self.predict(np.array([args[arg] for arg in self.args]))
|
455
|
+
|
456
|
+
def calculate_inpl_time_course(self, args: pd.DataFrame) -> None:
|
457
|
+
args[list(self.stoichiometries)] = pd.DataFrame(
|
458
|
+
[self.predict(y) for y in args.loc[:, self.args].to_numpy()],
|
459
|
+
index=args.index,
|
460
|
+
dtype=float,
|
461
|
+
)
|
462
|
+
|
351
463
|
|
352
464
|
@dataclass(kw_only=True)
|
353
465
|
class MockSurrogate(AbstractSurrogate):
|
354
466
|
"""Mock surrogate model for testing purposes."""
|
355
467
|
|
356
|
-
def
|
468
|
+
def predict(
|
357
469
|
self,
|
358
470
|
y: np.ndarray,
|
359
|
-
) ->
|
471
|
+
) -> dict[str, float]:
|
360
472
|
"""Predict outputs based on input data."""
|
361
|
-
return y
|
473
|
+
return dict(zip(self.stoichiometries, y, strict=True))
|
@@ -3,44 +3,43 @@ modelbase2/distributions.py,sha256=i456B0KYKdiGwuoVjoj3rey5lKdJmu9EVvacnfWXHGA,8
|
|
3
3
|
modelbase2/fit.py,sha256=WEI2lxLhdHFr6ax5xXrrkHUTxcEhmXyBHebfHEcXwCY,8172
|
4
4
|
modelbase2/fns.py,sha256=8JtIzPk3DAnNHz3LoJ1ukLFTjPNO1rNCeZ7VnRmJY2o,4503
|
5
5
|
modelbase2/label_map.py,sha256=LUwcOHQWiGfBGV5XUmPM_SOwM9IyDVcQVJ11DPfVpAo,17774
|
6
|
-
modelbase2/linear_label_map.py,sha256=
|
6
|
+
modelbase2/linear_label_map.py,sha256=6qs7SZIaiMcA0jRCdZXMe44lG7pBtKzYNMYSfNz2CfY,10317
|
7
7
|
modelbase2/mc.py,sha256=zlDL7e_udpIMRhSjfFJo5AwkigD0B_3H2rQxyelBuzI,16285
|
8
8
|
modelbase2/mca.py,sha256=nMS2VnzR2VEujCFUaj9WL82CNd-oxTb3jCHP8IlJvxA,8845
|
9
|
-
modelbase2/model.py,sha256=
|
9
|
+
modelbase2/model.py,sha256=3FSYqOMUqR2hkeqcqwnnEwyXK0V6cN0i-QpMR-_huoM,56730
|
10
10
|
modelbase2/nnarchitectures.py,sha256=OA1X4UHrn7gsLuuqxK6Dhv5aiKnQflhHezYCUV-NuO8,4012
|
11
11
|
modelbase2/npe.py,sha256=o876zHjyfJelGijSmCL0vUBfWbIhcbQyyPkwp8hZ4NA,8743
|
12
12
|
modelbase2/parallel.py,sha256=kX4Td5YoovDwZp6kX_3cfO6QtHSS9ieJ0bMZiKs3Xv8,5002
|
13
13
|
modelbase2/parameterise.py,sha256=7VrYxrQv0visraqUthWSnWfx-cxh2evlXbszIY5031U,690
|
14
14
|
modelbase2/paths.py,sha256=uatKXDa79uniUB2Z3dr8eBJVuUPXDI-o_bf-DqPKq1Y,1039
|
15
|
-
modelbase2/plot.py,sha256=
|
15
|
+
modelbase2/plot.py,sha256=72Oivv-jsCF9J9U7Uli15p5SnuEHSnHRXCaRP8uUaJo,22724
|
16
16
|
modelbase2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
-
modelbase2/scan.py,sha256=
|
17
|
+
modelbase2/scan.py,sha256=q6GmI0nqLtzmHjgs-AEcK2aaj6tcw8dvzmOE79yL2Pg,18117
|
18
18
|
modelbase2/scope.py,sha256=4twnEh8LrTmlLE-uRvubVkE3SSWejlLvtBzTCPqG3Aw,3710
|
19
|
-
modelbase2/simulator.py,sha256=
|
20
|
-
modelbase2/surrogates.py,sha256=
|
21
|
-
modelbase2/types.py,sha256=
|
19
|
+
modelbase2/simulator.py,sha256=3x_biwvwQmHCRs6C6R3dG5hUGwQqIgL0QQOrBR0zZQY,20986
|
20
|
+
modelbase2/surrogates.py,sha256=1ikylwZ5LdgnFAcZDOCx_lY_xvnQHxcTX_2z-L98r0s,8387
|
21
|
+
modelbase2/types.py,sha256=WDowHRr1YIvNNnK0clw_sBs5l2dwihT4av04Tt0jyFc,13502
|
22
22
|
modelbase2/experimental/__init__.py,sha256=IzgcQ7MtMII7n6cg1PMp-oZm06CNVR19ax2exvb9Ny0,444
|
23
|
-
modelbase2/experimental/
|
24
|
-
modelbase2/experimental/codegen.py,sha256=J_0iCtojwjmDXAfC8EqiXP0gmWaSH8MPkWvdLsZWsXU,6962
|
23
|
+
modelbase2/experimental/codegen.py,sha256=i0soAT64oMBILGsWonoSSVkYMWOcCTY4RJ4TZoYlTos,6962
|
25
24
|
modelbase2/experimental/diff.py,sha256=e7fjD9kqxkRUNxSevbAznd5cOlEdWJ6pj0y7Kd5KKrw,8973
|
26
25
|
modelbase2/experimental/notes.md,sha256=YlM2biTzub6jSlx-aDZaBYsvQcGwb7NHyVAbbl2acGE,238
|
27
26
|
modelbase2/experimental/strikepy.py,sha256=cKBs9InXR9mEPgx70Ynv0qkmAGfloksqinbpppTiC6U,19464
|
28
27
|
modelbase2/experimental/symbolic.py,sha256=QT82TSW42RSVsvXK2WTQW1XluXnflWzrHbx6RFr_YmY,9953
|
29
|
-
modelbase2/experimental/tex.py,sha256=
|
28
|
+
modelbase2/experimental/tex.py,sha256=48SrUEN-s2H_shHoXtimmLg_EDyCBa_vIVOXD2hlNbE,13664
|
30
29
|
modelbase2/integrators/__init__.py,sha256=kqmV6a0TRyLGR_XqbyAI652AfptYnXAUpqbSFg0CpP8,450
|
31
30
|
modelbase2/integrators/int_assimulo.py,sha256=VEQIZFZcEovLPy8i_jR8H8XcxBRQoRVmNzzCYzInPc0,4611
|
32
31
|
modelbase2/integrators/int_scipy.py,sha256=-_9MS55eTc9jI7tk-3X49p-c7zrydoXaCCvDTn7Tybw,4334
|
33
32
|
modelbase2/sbml/__init__.py,sha256=FBaQsVvrVc7QbCBXuG9tZOdSzHcqmmsaRbFx80rxrac,231
|
34
33
|
modelbase2/sbml/_data.py,sha256=XwT1sSxn6KLTXYMbk4ORbEAEgZhQDBfoyrjMBDAoY_s,1135
|
35
34
|
modelbase2/sbml/_export.py,sha256=9BLD3Qz86vlfDTZXwOnNOSVWq8mHrJoQjQmKJRZL_Wo,20285
|
36
|
-
modelbase2/sbml/_import.py,sha256=
|
35
|
+
modelbase2/sbml/_import.py,sha256=K-SL3aUaefqxxR0daCErisJ_Nd9rKdCmtjVu4rXD0_k,22063
|
37
36
|
modelbase2/sbml/_mathml.py,sha256=bNk9RQ_NQFDhY1R354p-gwqqHaIiyAwZ1xLPHHhiguQ,24436
|
38
37
|
modelbase2/sbml/_name_conversion.py,sha256=XK9DEyzhrD0GBBwwjK9RA0yORrDX5c-Uvx0VtKMR5rA,1325
|
39
38
|
modelbase2/sbml/_unit_conversion.py,sha256=dW_I6_Ou09ccwnp6LIdrPriIQnQUK5lJcjzM2Fawm6U,1927
|
40
39
|
modelbase2/surrogates/__init__.py,sha256=N_iXERECKvmrHiihwnyQEKOSBsmlGEuQhEotn-mWKdk,924
|
41
40
|
modelbase2/surrogates/_poly.py,sha256=zjlNL4iYR9G51gjvZPHe3CAYF-tgACGdIBe4QUYXLQk,3110
|
42
41
|
modelbase2/surrogates/_torch.py,sha256=CBS_3JzSgI2-xQrbq9CIXY0fJQsxbhBnWkG2TQyj7Zs,5885
|
43
|
-
modelbase2-0.
|
44
|
-
modelbase2-0.
|
45
|
-
modelbase2-0.
|
46
|
-
modelbase2-0.
|
42
|
+
modelbase2-0.6.0.dist-info/METADATA,sha256=Hjf5E6yvvCRbWsBwpqxF74_WInWGKVU6jMcqI9AR6VM,3344
|
43
|
+
modelbase2-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
44
|
+
modelbase2-0.6.0.dist-info/licenses/LICENSE,sha256=qvG2VolmSkrcocL34V1ieOx-Rn-fpVcUbb25gHzVgZw,35079
|
45
|
+
modelbase2-0.6.0.dist-info/RECORD,,
|