mxlpy 0.14.0__py3-none-any.whl → 0.16.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.
- mxlpy/integrators/int_assimulo.py +2 -1
- mxlpy/linear_label_map.py +2 -2
- mxlpy/mc.py +84 -70
- mxlpy/mca.py +97 -98
- mxlpy/meta/codegen_latex.py +1 -3
- mxlpy/meta/codegen_modebase.py +1 -1
- mxlpy/model.py +9 -13
- mxlpy/scan.py +40 -38
- mxlpy/simulator.py +19 -24
- mxlpy/types.py +32 -27
- {mxlpy-0.14.0.dist-info → mxlpy-0.16.0.dist-info}/METADATA +5 -3
- {mxlpy-0.14.0.dist-info → mxlpy-0.16.0.dist-info}/RECORD +14 -14
- {mxlpy-0.14.0.dist-info → mxlpy-0.16.0.dist-info}/WHEEL +0 -0
- {mxlpy-0.14.0.dist-info → mxlpy-0.16.0.dist-info}/licenses/LICENSE +0 -0
mxlpy/simulator.py
CHANGED
@@ -16,8 +16,10 @@ from typing import TYPE_CHECKING, Literal, Self, cast, overload
|
|
16
16
|
|
17
17
|
import numpy as np
|
18
18
|
import pandas as pd
|
19
|
+
from sympy import lambdify
|
19
20
|
|
20
21
|
from mxlpy.integrators import DefaultIntegrator
|
22
|
+
from mxlpy.symbolic import to_symbolic_model
|
21
23
|
|
22
24
|
__all__ = ["Result", "Simulator"]
|
23
25
|
|
@@ -362,31 +364,24 @@ class Simulator:
|
|
362
364
|
self._initialise_integrator()
|
363
365
|
|
364
366
|
def _initialise_integrator(self) -> None:
|
365
|
-
|
366
|
-
|
367
|
-
from mxlpy.symbolic import to_symbolic_model
|
368
|
-
|
369
|
-
_jacobian = None
|
367
|
+
jac_fn = None
|
370
368
|
if self.use_jacobian:
|
371
369
|
try:
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
#
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
("time", self.model.get_variable_names()),
|
388
|
-
jac.subs(self.model._parameters), # noqa: SLF001
|
389
|
-
)(t, y)
|
370
|
+
_jac = to_symbolic_model(self.model).jacobian()
|
371
|
+
_jac_fn = lambdify(
|
372
|
+
(
|
373
|
+
"time",
|
374
|
+
self.model.get_variable_names(),
|
375
|
+
self.model.get_parameter_names(),
|
376
|
+
),
|
377
|
+
_jac,
|
378
|
+
)
|
379
|
+
jac_fn = lambda t, x: _jac_fn( # noqa: E731
|
380
|
+
t,
|
381
|
+
x,
|
382
|
+
self.model._parameters.values(), # noqa: SLF001
|
383
|
+
)
|
384
|
+
|
390
385
|
except Exception as e: # noqa: BLE001
|
391
386
|
warnings.warn(str(e), stacklevel=2)
|
392
387
|
|
@@ -394,7 +389,7 @@ class Simulator:
|
|
394
389
|
self.integrator = self._integrator_type(
|
395
390
|
self.model,
|
396
391
|
[y0[k] for k in self.model.get_variable_names()],
|
397
|
-
|
392
|
+
jac_fn,
|
398
393
|
)
|
399
394
|
|
400
395
|
def clear_results(self) -> None:
|
mxlpy/types.py
CHANGED
@@ -158,7 +158,6 @@ type IntegratorType = Callable[
|
|
158
158
|
class Derived:
|
159
159
|
"""Container for a derived value."""
|
160
160
|
|
161
|
-
name: str
|
162
161
|
fn: RateFn
|
163
162
|
args: list[str]
|
164
163
|
|
@@ -174,36 +173,35 @@ class Derived:
|
|
174
173
|
"""
|
175
174
|
return cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
176
175
|
|
177
|
-
def calculate_inpl(self, dependent: dict[str, float]) -> None:
|
176
|
+
def calculate_inpl(self, name: str, dependent: dict[str, float]) -> None:
|
178
177
|
"""Calculate the derived value in place.
|
179
178
|
|
180
179
|
Args:
|
180
|
+
name: Name of the derived variable.
|
181
181
|
dependent: Dictionary of dependent variables.
|
182
182
|
|
183
183
|
"""
|
184
|
-
dependent[
|
185
|
-
float, self.fn(*(dependent[arg] for arg in self.args))
|
186
|
-
)
|
184
|
+
dependent[name] = cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
187
185
|
|
188
|
-
def calculate_inpl_time_course(self, dependent: pd.DataFrame) -> None:
|
186
|
+
def calculate_inpl_time_course(self, name: str, dependent: pd.DataFrame) -> None:
|
189
187
|
"""Calculate the derived value in place.
|
190
188
|
|
191
189
|
Args:
|
190
|
+
name: Name of the derived variable.
|
192
191
|
dependent: Dictionary of dependent variables.
|
193
192
|
|
194
193
|
"""
|
195
194
|
try:
|
196
|
-
dependent[
|
195
|
+
dependent[name] = self.fn(*dependent.loc[:, self.args].to_numpy().T)
|
197
196
|
except ValueError: # e.g. numpy.where
|
198
197
|
sub = dependent.loc[:, self.args].to_numpy()
|
199
|
-
dependent[
|
198
|
+
dependent[name] = [self.fn(*row) for row in sub]
|
200
199
|
|
201
200
|
|
202
201
|
@dataclass(kw_only=True, slots=True)
|
203
202
|
class Readout:
|
204
203
|
"""Container for a readout."""
|
205
204
|
|
206
|
-
name: str
|
207
205
|
fn: RateFn
|
208
206
|
args: list[str]
|
209
207
|
|
@@ -219,36 +217,35 @@ class Readout:
|
|
219
217
|
"""
|
220
218
|
return cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
221
219
|
|
222
|
-
def calculate_inpl(self, dependent: dict[str, float]) -> None:
|
220
|
+
def calculate_inpl(self, name: str, dependent: dict[str, float]) -> None:
|
223
221
|
"""Calculate the readout in place.
|
224
222
|
|
225
223
|
Args:
|
224
|
+
name: Name of the derived variable.
|
226
225
|
dependent: Dictionary of dependent variables.
|
227
226
|
|
228
227
|
"""
|
229
|
-
dependent[
|
230
|
-
float, self.fn(*(dependent[arg] for arg in self.args))
|
231
|
-
)
|
228
|
+
dependent[name] = cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
232
229
|
|
233
|
-
def calculate_inpl_time_course(self, dependent: pd.DataFrame) -> None:
|
230
|
+
def calculate_inpl_time_course(self, name: str, dependent: pd.DataFrame) -> None:
|
234
231
|
"""Calculate the derived value in place.
|
235
232
|
|
236
233
|
Args:
|
234
|
+
name: Name of the derived variable.
|
237
235
|
dependent: Dictionary of dependent variables.
|
238
236
|
|
239
237
|
"""
|
240
238
|
try:
|
241
|
-
dependent[
|
239
|
+
dependent[name] = self.fn(*dependent.loc[:, self.args].to_numpy().T)
|
242
240
|
except ValueError: # e.g. numpy.where
|
243
241
|
sub = dependent.loc[:, self.args].to_numpy()
|
244
|
-
dependent[
|
242
|
+
dependent[name] = [self.fn(*row) for row in sub]
|
245
243
|
|
246
244
|
|
247
245
|
@dataclass(kw_only=True, slots=True)
|
248
246
|
class Reaction:
|
249
247
|
"""Container for a reaction."""
|
250
248
|
|
251
|
-
name: str
|
252
249
|
fn: RateFn
|
253
250
|
stoichiometry: Mapping[str, float | Derived]
|
254
251
|
args: list[str]
|
@@ -272,29 +269,29 @@ class Reaction:
|
|
272
269
|
"""
|
273
270
|
return cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
274
271
|
|
275
|
-
def calculate_inpl(self, dependent: dict[str, float]) -> None:
|
272
|
+
def calculate_inpl(self, name: str, dependent: dict[str, float]) -> None:
|
276
273
|
"""Calculate the reaction in place.
|
277
274
|
|
278
275
|
Args:
|
276
|
+
name: Name of the derived variable.
|
279
277
|
dependent: Dictionary of dependent variables.
|
280
278
|
|
281
279
|
"""
|
282
|
-
dependent[
|
283
|
-
float, self.fn(*(dependent[arg] for arg in self.args))
|
284
|
-
)
|
280
|
+
dependent[name] = cast(float, self.fn(*(dependent[arg] for arg in self.args)))
|
285
281
|
|
286
|
-
def calculate_inpl_time_course(self, dependent: pd.DataFrame) -> None:
|
282
|
+
def calculate_inpl_time_course(self, name: str, dependent: pd.DataFrame) -> None:
|
287
283
|
"""Calculate the derived value in place.
|
288
284
|
|
289
285
|
Args:
|
286
|
+
name: Name of the derived variable.
|
290
287
|
dependent: Dictionary of dependent variables.
|
291
288
|
|
292
289
|
"""
|
293
290
|
try:
|
294
|
-
dependent[
|
291
|
+
dependent[name] = self.fn(*dependent.loc[:, self.args].to_numpy().T)
|
295
292
|
except ValueError: # e.g. numpy.where
|
296
293
|
sub = dependent.loc[:, self.args].to_numpy()
|
297
|
-
dependent[
|
294
|
+
dependent[name] = [self.fn(*row) for row in sub]
|
298
295
|
|
299
296
|
|
300
297
|
@dataclass(kw_only=True, slots=True)
|
@@ -357,7 +354,7 @@ class McSteadyStates:
|
|
357
354
|
variables: pd.DataFrame
|
358
355
|
fluxes: pd.DataFrame
|
359
356
|
parameters: pd.DataFrame
|
360
|
-
|
357
|
+
mc_to_scan: pd.DataFrame
|
361
358
|
|
362
359
|
def __iter__(self) -> Iterator[pd.DataFrame]:
|
363
360
|
"""Iterate over the concentration and flux steady states."""
|
@@ -464,11 +461,19 @@ class AbstractSurrogate:
|
|
464
461
|
)
|
465
462
|
)
|
466
463
|
|
467
|
-
def calculate_inpl(
|
464
|
+
def calculate_inpl(
|
465
|
+
self,
|
466
|
+
name: str, # noqa: ARG002, for API compatibility
|
467
|
+
args: dict[str, float],
|
468
|
+
) -> None:
|
468
469
|
"""Predict outputs based on input data."""
|
469
470
|
args |= self.predict(np.array([args[arg] for arg in self.args]))
|
470
471
|
|
471
|
-
def calculate_inpl_time_course(
|
472
|
+
def calculate_inpl_time_course(
|
473
|
+
self,
|
474
|
+
name: str, # noqa: ARG002, for API compatibility
|
475
|
+
args: pd.DataFrame,
|
476
|
+
) -> None:
|
472
477
|
"""Predict outputs based on input data."""
|
473
478
|
args[list(self.stoichiometries)] = pd.DataFrame(
|
474
479
|
[self.predict(y) for y in args.loc[:, self.args].to_numpy()],
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mxlpy
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.16.0
|
4
4
|
Summary: A package to build metabolic models
|
5
5
|
Author-email: Marvin van Aalst <marvin.vanaalst@gmail.com>
|
6
6
|
Maintainer-email: Marvin van Aalst <marvin.vanaalst@gmail.com>
|
@@ -60,7 +60,9 @@ Provides-Extra: torch
|
|
60
60
|
Requires-Dist: torch>=2.5.1; extra == 'torch'
|
61
61
|
Description-Content-Type: text/markdown
|
62
62
|
|
63
|
-
<
|
63
|
+
<p align="center">
|
64
|
+
<img src="docs/assets/logo-diagram.png" width="600px" alt='mxlpy-logo'>
|
65
|
+
</p>
|
64
66
|
|
65
67
|
# mxlpy
|
66
68
|
|
@@ -70,7 +72,7 @@ Description-Content-Type: text/markdown
|
|
70
72
|

|
71
73
|
[](https://github.com/astral-sh/ruff)
|
72
74
|
[](https://github.com/PyCQA/bandit)
|
73
|
-
[](https://pepy.tech/
|
75
|
+
[](https://pepy.tech/projects/mxlpy)
|
74
76
|
|
75
77
|
[docs-badge]: https://img.shields.io/badge/docs-main-green.svg?style=flat-square
|
76
78
|
[docs]: https://computational-biology-aachen.github.io/mxlpy/
|
@@ -4,10 +4,10 @@ mxlpy/fit.py,sha256=LwSoLfNVrqSlTtuUApwH36LjzGU0HLs4C_2qqTTjXFE,7859
|
|
4
4
|
mxlpy/fns.py,sha256=ct_RFj9koW8vXHyr27GnbZUHUS_zfs4rDysybuFiOaU,4599
|
5
5
|
mxlpy/identify.py,sha256=af52SCG4nlY9sSw22goaIheuvXR09QYK4ksCT24QHWI,1946
|
6
6
|
mxlpy/label_map.py,sha256=urv-QTb0MUEKjwWvKtJSB8H2kvhLn1EKfRIH7awQQ8Y,17769
|
7
|
-
mxlpy/linear_label_map.py,sha256=
|
8
|
-
mxlpy/mc.py,sha256=
|
9
|
-
mxlpy/mca.py,sha256=
|
10
|
-
mxlpy/model.py,sha256
|
7
|
+
mxlpy/linear_label_map.py,sha256=DqzN_akacPccZwzYAR3ANIdzAU_GU6Xe6gWV9DHAAWU,10282
|
8
|
+
mxlpy/mc.py,sha256=oYd8a3ycyZLyh-ZxTYUjDRNfsCcwSQaLWssxv0yC5Cc,17399
|
9
|
+
mxlpy/mca.py,sha256=1_qBX9lHI6svXSebtwvMldAMwPlLqMylAPmxMbMQdWw,9359
|
10
|
+
mxlpy/model.py,sha256=qzol8nDSbM3HdESh50c4UFjn6Pw5JwcvhQ5AyKnbyvc,57576
|
11
11
|
mxlpy/npe.py,sha256=oiRLA43-qf-AcS2KpQfJIOt7-Ev9Aj5sF6TMq9bJn84,8747
|
12
12
|
mxlpy/parallel.py,sha256=kX4Td5YoovDwZp6kX_3cfO6QtHSS9ieJ0bMZiKs3Xv8,5002
|
13
13
|
mxlpy/parameterise.py,sha256=2jMhhO-bHTFP_0kXercJekeATAZYBg5FrK1MQ_mWGpk,654
|
@@ -15,17 +15,17 @@ mxlpy/paths.py,sha256=TK2wO4N9lG-UV1JGfeB64q48JVDbwqIUj63rl55MKuQ,1022
|
|
15
15
|
mxlpy/plot.py,sha256=4uu-6d8LH-GWX-sG_TlSpkSsnikv1DLTtnjJzA7nuRA,24670
|
16
16
|
mxlpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
mxlpy/report.py,sha256=h7dhcBzPFydLPxdsEXokzDf7Ce4PirXMsvLqlDZLSWM,7181
|
18
|
-
mxlpy/scan.py,sha256
|
19
|
-
mxlpy/simulator.py,sha256=
|
20
|
-
mxlpy/types.py,sha256=
|
18
|
+
mxlpy/scan.py,sha256=FBPpjv66v4IWZ5OwG_EWUdrucLWR9gq_XEsLFC-otaw,18969
|
19
|
+
mxlpy/simulator.py,sha256=9Ne4P5Jrwgx4oAlljPvCqSCCy98_5Lv1B87y1AkbI4c,21041
|
20
|
+
mxlpy/types.py,sha256=GbdyzEDTN8QfUH6-XXdNgf_TzqIXaYvcZGxaXc5kVio,14509
|
21
21
|
mxlpy/experimental/__init__.py,sha256=kZTE-92OErpHzNRqmgSQYH4CGXrogGJ5EL35XGZQ81M,206
|
22
22
|
mxlpy/experimental/diff.py,sha256=4bztagJzFMsQJM7dlun_kv-WrWssM8CIw7gcL63hFf8,8952
|
23
23
|
mxlpy/integrators/__init__.py,sha256=kqmV6a0TRyLGR_XqbyAI652AfptYnXAUpqbSFg0CpP8,450
|
24
|
-
mxlpy/integrators/int_assimulo.py,sha256=
|
24
|
+
mxlpy/integrators/int_assimulo.py,sha256=TCBWQd558ZeRdBba1jCNsFyLBOssKvm8dXK36Aqg4_k,4817
|
25
25
|
mxlpy/integrators/int_scipy.py,sha256=dFHlYTeb2zX97f3VuNdMJdI7WEYshF4JAIgprKKk2z4,4581
|
26
26
|
mxlpy/meta/__init__.py,sha256=Jyy4063fZy6iT4LSwjPyEAVr4N_3xxcLc8wDBoDPyKc,278
|
27
|
-
mxlpy/meta/codegen_latex.py,sha256=
|
28
|
-
mxlpy/meta/codegen_modebase.py,sha256=
|
27
|
+
mxlpy/meta/codegen_latex.py,sha256=R0OJqzE7PnOCWLk52C3XWuRb-zI2eYTvV2oJZJvPsOE,13414
|
28
|
+
mxlpy/meta/codegen_modebase.py,sha256=_ZAW4NvXhKwJQLGz5hkwwZpL2JMAJlfG-GUWkYIiNvw,3124
|
29
29
|
mxlpy/meta/codegen_py.py,sha256=xSdeuEGPGc-QKRMgJO4VSPGMlxCPEV5prkKjNQ2D2hg,3483
|
30
30
|
mxlpy/meta/source_tools.py,sha256=EN3OoGQaXeIsDTJvA7S15-xDBra3DCIyFZEJ6h0Fy0k,11125
|
31
31
|
mxlpy/nn/__init__.py,sha256=yUc4o-iqfVVzkq9tZCstWwizrCqNlMft0YUwWGFFO-E,219
|
@@ -44,7 +44,7 @@ mxlpy/surrogates/_torch.py,sha256=E_1eDUlPSVFwROkdMDCqYwwHE-61pjNMJWotnhjzge0,58
|
|
44
44
|
mxlpy/symbolic/__init__.py,sha256=3hQjCMw8-6iOxeUdfnCg8449fF_BRF2u6lCM1GPpkRY,222
|
45
45
|
mxlpy/symbolic/strikepy.py,sha256=r6nRtckV1nxKq3i1bYYWZOkzwZ5XeKQuZM5ck44vUo0,20010
|
46
46
|
mxlpy/symbolic/symbolic_model.py,sha256=YL9noEeP3_0DoKXwMPELtfmPuP6mgNcLIJgDRCkyB7A,2434
|
47
|
-
mxlpy-0.
|
48
|
-
mxlpy-0.
|
49
|
-
mxlpy-0.
|
50
|
-
mxlpy-0.
|
47
|
+
mxlpy-0.16.0.dist-info/METADATA,sha256=ySMK4udu6wgaUpG7Wn0sa-XYUkaVz4u19C5PjMEM5p0,4551
|
48
|
+
mxlpy-0.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
49
|
+
mxlpy-0.16.0.dist-info/licenses/LICENSE,sha256=bEzjyjy1stQhfRDVaVHa3xV1x-V8emwdlbMvYO8Zo84,35073
|
50
|
+
mxlpy-0.16.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|