Architecture and Data Flow
This page describes the project-level code areas that exist in this repository and how data flows through the TFOpt workflow.
Project Areas
| Area | Role |
|---|---|
tfopt/api.py |
The library: configuration, input checks, run, results; used by the command line and the GUI |
tfopt/cli.py, tfopt/app/ |
The tfopt command and the tfopt-app GUI |
tfopt/processing/ |
Checks input tables, maps TF → target edges, selects each TF's series and aligns input1 to the RNA times |
tfopt/local/ |
Runs the constrained local TF-regulation optimization and writes its outputs |
tfopt/fitanalysis/ |
Post-fit figures and the workbook, regulatory, curve and network helpers |
tfopt/analysis/ |
Regulatory readout, curve similarity and model diagrams of a results folder, as tables and files |
tfopt/optimality/ |
Feasibility, projected stationarity and KKT diagnostics |
tfopt/bundle/ |
Writes and checks run bundles against their contract |
tfopt/examples/ |
The synthetic example project, generated from a fixed seed |
processing/ |
Alias of tfopt.processing in a clone |
config/ |
CLI wrapper and logging helpers |
config_loader.py |
Finds and loads config.toml with mode-specific overrides |
Data Flow
flowchart TD
A["input1 (TF protein and sites)<br/>input3 (mRNA)<br/>input4 (TF → target)"]
subgraph prep ["tfopt/processing/"]
B["cleanup.py, map.py<br/>check tables, map edges"]
C["tfseries.py<br/>TF base series, sites, MS → RNA times"]
end
subgraph opt ["tfopt/local/"]
D["optcon/, utils/<br/>fixed arrays and parameter layout"]
E["objfn/<br/>JAX model and seven losses"]
F["opt/<br/>scipy-slsqp (default) or JAXopt, multistart"]
G["exporter/<br/>workbook, plots, LaTeX, report"]
end
subgraph post ["after the fit"]
H["optimality/<br/>feasibility and KKT"]
I["fitanalysis/, analysis/<br/>figures, readout, similarity"]
J["bundle/<br/>run bundle (zip)"]
end
subgraph runtime ["runtime configuration"]
K["config_loader.py, tfopt.api.load_config<br/>config.toml"]
end
A --> B --> C --> D --> E --> F --> H --> G
G --> I
G --> J
K --> D
K --> F
tfopt run, tfopt-local and the GUI all go through tfopt.api.run.
Directory Summary
TFOpt/
├── config/
│ ├── __init__.py
│ ├── cli.py
│ └── logconf.py
├── config_loader.py
├── config.toml
├── processing/ # alias of tfopt.processing
├── tfopt/
│ ├── __init__.py
│ ├── api.py
│ ├── cli.py
│ ├── analysis/
│ ├── app/
│ ├── bundle/
│ ├── examples/
│ ├── fitanalysis/
│ ├── local/
│ ├── optimality/
│ └── processing/
├── notebooks/ # tutorials 00–10 and the tutorial dataset (notebooks/data/)
├── docs/ # this site (Zensical); docs/examples/ holds the use cases
└── tools/ # build_tutorials.py, build_brand.py
Runtime Paths
The docs build and the development tasks run with the repository root on PYTHONPATH, so imports resolve to the
checked-out code. Importing TFOpt enables JAX float64 before any array is created, reads no configuration and
creates no file or folder. Generated output (results folders, notebooks/outputs/, site/, docs/tutorials/) stays
in folders ignored by git.
pixi.toml maps conda-forge names to PyPI names explicitly, so installing needs no remote mapping lookup; the lock
file keeps package checksums and TLS verification.
Provenance and migration
TFOpt was extracted from the integrated PhosKinTime source into an independent package with KinOpt's repository
layout. References inspected for the extraction: KinOpt 78fb06edc2040b8a1716d3917962279c30c7b9c6, PhosKinTime
6b8dab729e585c97499aa2527d48a4486be1ca1a, TFOpt baseline 6510062cb68fb85ff48452ae6440fe2db4075ad3.
| KinOpt reference | Previous TFOpt | TFOpt | Action | Implication |
|---|---|---|---|---|
kinopt/local/ |
local/ |
tfopt/local/ |
Move and adapt | Public numerical and runner interfaces preserved |
kinopt/evol/ |
evol/ |
none | Remove | Local optimization only; the history keeps the original source |
kinopt/fitanalysis/helpers/ |
fitanalysis/helper.py |
tfopt/fitanalysis/helpers/ |
Move | TF-specific diagnostics preserved |
kinopt/optimality/ |
none | tfopt/optimality/ |
Create | TF α/β feasibility, projected stationarity, KKT |
config/, config_loader.py |
external imports | same root paths | Create | Independent TOML configuration |
processing/ |
embedded I/O | tfopt/processing/ |
Adapt | TF → target edges, not kinase mapping |
docs/ |
READMEs | docs/, zensical.toml |
Create | Zensical site with KaTeX and Mermaid |
notebooks/ |
none | notebooks/00–10 |
Create | TF examples and the original CSV schemas |
pixi.toml, pixi.lock |
none | same | Create | CPU, Python 3.12, no evolutionary dependencies |
The extracted numerical, constraint, filtering, exporter and analysis sources matched the baseline; no newer formulas
were ported. The executable loaders establish input1 = TF signals, input3 = mRNA, input4 = Source TF / Target
gene (comments in the integrated configuration had input1 and input3 reversed).
Public contracts preserved: objective_, objective_wrapper, compute_predictions; run_optimizer,
run_optimizer_multistart, MultiStartConfig, generate_multistart_x0; get_optimization_parameters,
postprocess_results; the CSV loaders, fixed arrays, Excel and plotting functions. Optional keyword arguments add
methods, regulator masks and reproducibility settings without changing positional order.
Changes to the original behaviour:
- The prediction is clipped at zero in both the objective and the report (the original report did not clip).
- Padded regulator slots are fixed to zero; they never contribute or absorb α (padded-α allocation fix).
- Loss codes 0–6 keep their formulas, mean normalization and 1e-6 regularization coefficients; JAX float64 replaces the Numba objective, checked against values captured from the original (see Testing).
- T6/T6c (TF Base Series): the TF base series is the input1 protein row, else the TF's mRNA,
and input1 series are taken at the RNA times by actual time. The former rules remain available as
tf_protein_source = "legacy_first_site"andms_alignment = "legacy_position"for control runs. - The default solver is
scipy-slsqp(exact constraints, analytic JAX gradients, as KinOpt); bareSLSQPandtrust-constrnames raise an error. No automatic normalization is added. - The time grids come only from the configuration: there is no built-in RNA or MS grid.
- The repository's
scripts/and the Streamlit dashboard were replaced bytfoptsubcommands andtfopt-app(Command line).