Metadata-Version: 2.4
Name: equilibrator-pathway-core
Version: 0.1.0
Summary: MDF and enzyme cost minimization for fully specified pathway models, with no compound database
Author-email: Elad Noor <elad.noor@weizmann.ac.il>
License-Expression: MIT
Project-URL: repository, https://gitlab.com/equilibrator/equilibrator-pathway-core/
Keywords: eQuilibrator,pathway analysis,max-min driving force,enzyme cost minimization
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: scipy>=1.13
Requires-Dist: cvxpy>=1.6
Requires-Dist: sbtabpy>=1.1.1
Dynamic: license-file

# equilibrator-pathway-core

Max-min driving force (MDF) and enzyme cost minimization (ECM) for **fully
specified** pathway models, with no compound database.

This is the lower layer of
[equilibrator-pathway](https://gitlab.com/equilibrator/equilibrator-pathway).
It analyses model SBtab files that already carry everything the optimisation
needs -- stoichiometry, concentration bounds, fluxes and standard Gibbs energies
-- and it never predicts or looks anything up. That is what lets it install in
a few megabytes of Python on top of numpy, including in the browser via
[Pyodide](https://pyodide.org).

| | this package | equilibrator-pathway |
| --- | --- | --- |
| MDF, ECM on a model SBtab | yes | yes (re-exported) |
| network SBtabs, formula search, identifier resolution | -- | yes |
| dG'0 prediction (Component Contribution) | -- | yes |
| dG'0 uncertainty, MDMC | -- | yes |
| pint `Q_` public API | -- | yes |
| compound database, sqlalchemy, pint | never | yes |

## Units

Everything here works on plain floats in one canonical set of units -- M,
kJ/mol, K, 1/s, Da -- documented in `equilibrator_pathway_core.constants`.
Units are attached at the boundary, by equilibrator-pathway's pint adapter or by
the browser client's string parser.

## Staying small

Importing this package must not pull in the equilibrator database stack. That is
tested directly, in a fresh interpreter, by `tests/test_isolation.py`, which
fails if `equilibrator_api`, `equilibrator_cache`, `component_contribution`,
`sqlalchemy`, `pint` or `matplotlib` appear in `sys.modules`. A dependency added
to `pyproject.toml` without the code that needs it is equally unwelcome.

## Status

In place:

| module | what | needs sbtabpy |
| --- | --- | --- |
| `constants.py` | R, T, standard concentrations | -- |
| `ecm.py` | the enzyme cost function and ECM | -- |
| `mdf.py` | the MDF linear program | -- |
| `errors.py` | `ModelError`, `SolverFailure`, `ConfigurationError` | -- |
| `units.py` | unit strings to canonical floats | -- |
| `model.py` | model SBtab to arrays: S, bounds, fluxes, dG'0, water | yes |
| `ecm_model.py` | an ECM model's Parameter table | yes |
| `solution.py` | result tables and the SBtab report | yes |
| `configuration.py` | the editable Configuration options, their schema, and applying edits | yes |

Both equilibrator-pathway and the browser client run MDF and ECM through this
package; the browser also reads models (`model.load_model`), edits their
Configuration (`configuration.py`) and writes reports with it.

The SBtab modules use sbtabpy directly, and need sbtabpy **1.1.1 or later**.
1.1.0 was the first release with no required dependencies (earlier ones
declared pandas, pyarrow, python-libsbml and openpyxl, which its parser never
imports); 1.1.1 added the dictionary rows, attribute defaults and pandas-free
`SBtabTable.from_rows` that replaced the core's own adapter module.
`tests/test_isolation.py` still forbids all four: nothing installs them by
default now, but the test is what guarantees the core never imports them, and
so stays loadable in the browser.

The extraction plan is in
`enzyme-cost-minimization-webapp/CORE_EXTRACTION_PLAN.txt`. Correctness is held
to the golden results frozen in that repository (`tests/golden/`), which record
what equilibrator-pathway and the browser port each produced while they were
still independent implementations. After the move, both consumers reproduce
every one of those 482 numbers **bit for bit**, not merely within the checker's
1e-6 tolerance.

Where the two replaced copies disagreed, see the docstring of `ecm.py` for
which behaviour was kept and why. In short: the port's `get_volumes` (the
server's zeroed the last metabolite when a model had no water), and working
versions of `get_fluxes` and `is_feasible`, which raised on every call in
equilibrator-pathway without any test noticing.

```sh
PYTHONPATH=src pytest tests/
```
