Skip to content

Homogenizing exchange-flux custom_data naming under R_EX_* - #441

Closed
othmya wants to merge 464 commits into
MathCancer:masterfrom
PhysiCelldFBA:homogenize-rex-flux-naming
Closed

othmya wants to merge 464 commits into
MathCancer:masterfrom
PhysiCelldFBA:homogenize-rex-flux-naming

Conversation

@othmya

@othmya othmya commented Oct 28, 2026

Copy link
Copy Markdown

Two of the seven FBA sample projects already used the target convention
(generic loop over substrate_exchanges, bare R_EX_* ids, safe
set_custom_data() helper): bacterial_colony and cancer_core_metabolism.
No changes were needed there; both were rebuilt as no-op sanity checks.

Changes per project

Project custom.cpp/.h XML custom_data Scripts Build
ecoli_acetic_switch Generic substrate_exchanges loop + safe set_custom_data; now also records R_EX_*_lb. Added dFBA includes to custom.h. Removed dead oxygen_flux/glucose_flux/acetate_flux/co2_flux (R_EX_* + _lb were already declared alongside them) in PhysiCell_settings.xml and PhysiCell_settings_pfba.xml. plot_ecoli_figure_a.py: domain volume in 2D runs now uses the dz slab instead of the ignored z_min/z_max range (ported from the feature/acetate-rex-fluxes branch). ✅ ecoli-dfba linked
dfba_unit_test Same pattern. Renamed oxygen_flux/glucose_flux/acetate_flux → R_EX_o2_e/R_EX_glc__D_e/R_EX_ac_e (+ _lb) across all 6 configs (main, mass-conversion, 4 voxel-sharing-test configs). check_update_order.py column names updated. ✅ dfba-unit-test linked
human_template Same pattern. Renamed oxygen_flux/glucose_flux/lactate_flux → R_EX_o2_e/R_EX_glc_e/R_EX_lac_D_e (+ _lb) in PhysiCell_settings.xml. None reference these fields. ✅ human-template linked
metabolic_driven_motility Same pattern, including the ADDON_PHYSIDFBA death short-circuit branch. Non-exchange fields (growth_factor, metabolic_mode, atp_flux, motility_atp_flux, motility_speed_fraction) untouched. Removed the now-dead old-named fields (R_EX_*/_lb were already declared alongside them but unused) in both motility configs. fluxes_analysis.py, dynamic_analysis.py, composite_figure.py updated; dynamics_analysis.ipynb's cached output (stale printed column list) left as-is. ✅ ecoli-dfba-motility linked
crossfeeding The two per-species dispatcher functions (post_update_intracellular_c_beijerinckii/_m_barkeri) and the dispatching post_update_intracellular merged into one generic function — each cell only has its own species' exchanges, so no CB_/MB_ prefix or manual cross-zeroing is needed. Also now records _lb. Both cell types' custom_data blocks rewritten to the union of exchanges (R_EX_glc_D_e, R_EX_h2_e, R_EX_nh4_e, R_EX_pi_e, R_EX_so4_e, R_EX_ac_e, R_EX_co2_e, R_EX_ch4_e) + _lb, bare growth_rate/fba_infeasible. config.py, lib/io.py (kept old names as fallback aliases for pre-existing output), plots/spatial_composite.py, README.md updated. ✅ crossfeeding linked

Verification performed

  • Every touched project (and the two already-homogenized ones) was compiled and linked
    via its classic make <target>-sample && make path in an isolated git worktree
    (so the shared repo's root files were never mutated), using the real toolchain
    (g++ 11.4, libsbml 5.20.4, Clp/CoinUtils) already available in this sandbox.
  • All touched Python scripts were syntax-checked with py_compile.
  • A repo-wide grep confirms no stray references to the retired names remain outside
    the intentional backward-compat aliases in crossfeeding's lib/io.py.

migp11 and others added 30 commits December 16, 2025 10:21
Restructuring PhysiCell dFBA XML settings block . now the sbml model is set inside the settings block in the PhysiCell_settings. General cleaning and fixes of the files in the intracellular.cpp .
update resume a sim with a sample main.cpp and README
 Co-authored-by: Daniel Bergman <danielrbergman@gmail.com>
Its custom function was dynamically changing secretion reates but they were not updated internally.
Added `set_internal_uptake_constants` to force the update.
othmya and others added 28 commits October 27, 2026 17:02
- Remove config/PhysiCell_settings_crossfeeding.xml: byte-identical to the
  default config/PhysiCell_settings.xml (same redundancy pattern already
  fixed in dfba_unit_test's Unit_test_mass_conversion.xml).
- sample_projects/Makefile-default's crossfeeding populate rule had a step
  copying the now-removed file over the default settings after already
  copying the whole config/ directory (a no-op since they were identical)
  -- dropped that step.
- Fixed a stale comment in scripts/paper_figures/config.py referencing the
  removed filename.
- Updated README: Build & run no longer needs to pass the settings file
  explicitly, and now only shows the repository-root workflow (dropped the
  'from this directory standalone' variant, per review -- all READMEs are
  moving to repo-root-only instructions). Dropped the intro's mention of
  scheduled glucose refeeding: apply_glucose_dirichlet_refeed_schedule() is
  only invoked from a commented-out line in main.cpp, so it isn't actually
  active; apply_initial_glucose_refeed_setup() is real but is not a
  'schedule'.

Verified: 'make crossfeeding && make' populates and builds cleanly (no
missing-file cp error), binary runs successfully.
- Remove scripts/figure_generation.py (stale copy of composite_figure.py)
  and the unused scripts/plot_df_journal_style_ext.py.
- Point dynamics_analysis.ipynb at the output folder relative to the project.
- README: Build & run from the repository root; add Figure reproducibility
  section for Figure 7, using the K_m values of the upstream configs
  (0.02 mM growth-permissive, 0.5 mM motility-only).
- dfba_unit_test, ecoli_acetic_switch, bacterial_colony,
  cancer_core_metabolism, crossfeeding: Figure reproducibility table mapping
  each manuscript figure (main text and supplement) to its script, XML input
  and expected output.
- Build & run shows the repository-root workflow only.
- Makefile PROGRAM_NAME is human-template; CMake target set explicitly to
  human-template instead of the directory name.
- README rewritten as a template guide: setup steps, disabled optional
  inputs (rules.csv, initial.mat, dirichlet.mat), full file list, and the
  COIN-OR Clp / libSBML requirements for the CMake route.
- Verified: make human-template-sample && make builds ./human-template,
  which runs to its configured end time.
- Makefile: replace the cancer-metabolism-sample rule with
  human-template-sample; copy dfba_unit_test config recursively; drop the
  crossfeeding default-settings copy that no longer exists. The root
  Makefile now matches sample_projects/Makefile-default.
- CMakeLists.txt: add_subdirectory path for human_template. The
  ecoli_acetic_switch line remains commented out, as in HEAD.
- Move dfba_configurator.py and generate_dfba_yaml.py to addons/dFBA/utils/
  (history kept with git mv); the rest of beta/ is unchanged.
- Add addons/dFBA/utils/README.md with requirements and usage for both scripts.
- State what the configurator generates (substrates, cell definitions, dFBA
  block) and what stays hand-edited.
- List known limitations: sbml_path under settings, positive nuclear volume
  required, unit labels written for Vmax and max_growth_rate.
…pFBA scenario

- PhysiCell_settings.xml replaced by the final FBA configuration (dx 2, all time
  steps 0.001 incl. intracellular_dt, 3 threads, SVG off, 5-min full-data
  interval, save folder output). Add PhysiCell_settings_pfba.xml with the
  parsimonious second stage, saving to output_pfba.
- Add Ecoli_core.yaml and Ecoli_core_pfba.yaml, generated from the two XMLs and
  checked by regenerating the XMLs with addons/dFBA/utils/dfba_configurator.py.
- README: document both scenarios; Figure A axis is 0-6 h.
…BA YAML

- PhysiCell_settings.xml: domain +-500 um, 4 mM glucose and 5 mM oxygen (initial
  and boundary values), and five lower-bound custom_data entries. Colony radius
  10 um, max_time 600 min, dx 2, time steps 0.001, full data every 30 min, SVG
  on and save folder output are unchanged.
- Add Ecoli_core.yaml, generated from the XML and checked by regenerating the
  XML with addons/dFBA/utils/dfba_configurator.py.
- README: document the default run settings and outputs.
- PhysiCell_settings.xml and PhysiCell_settings_pfba.xml: SVG output on, every
  10 min (substrate plot kept; ~12 MB per snapshot at dx 2).
- README: document the SVG interval.
… its dFBA YAMLs

- PhysiCell_settings.xml and PhysiCell_settings_pfba.xml replaced by the final
  configurations: 6 threads, save folders output and output_pfba, and 23
  lower-bound custom_data entries. dFBA settings are unchanged.
- Add MCF7_core.yaml and MCF7_core_pfba.yaml, generated from the two XMLs and
  checked by regenerating the XMLs with addons/dFBA/utils/dfba_configurator.py.
  They replace the earlier generator output.
- README: document both scenarios, the YAMLs and the run settings.
… dFBA YAML

- PhysiCell_settings.xml replaced by the final configuration: dx 1.25, dt_diffusion
  and intracellular_dt 0.001, save folder output, and 16 lower-bound custom_data
  entries. max_time stays 3000 min (50 h) as used by the figure pipeline.
- crossfeeding.yaml regenerated from the XML (both species in one file) and checked
  by regenerating the XML with addons/dFBA/utils/dfba_configurator.py.
- README: document the default run settings and the YAML.
…d their dFBA YAMLs

- Both scenario configs now share the final settings (6 threads, eight lower-bound/flux
  custom_data entries) and write to separate folders: output_motility_prolif
  (growth-permissive) and output_motility (motility only). They differ only in glucose K_m,
  glucose_threshold_low and motility_cost_at_vmax.
- Remove PhysiCell_settings.xml (byte-identical to PhysiCell_settings_motility_proliferation.xml),
  PhysiCell_settings_no_motility.xml and PhysiCell_settings_multiple_sources.xml.
- Add Ecoli_core_motility_proliferation.yaml and Ecoli_core_motility.yaml, generated from
  the two XMLs and checked by regenerating the XMLs with addons/dFBA/utils/dfba_configurator.py
  (cell volume is set from reference_volume).
- dynamic_analysis.py and dynamics_analysis.ipynb default to output_motility_prolif.
- README: document the two scenarios, their output folders and the YAMLs.
addons/dFBA/scripts/dfba_config.yaml and dfba_config_crossfeeding.yaml were stand-alone
examples that no project or script referenced. Each sample project now ships the YAML that
defines its own XML (config/<model>.yaml), which can be used as input to
addons/dFBA/utils/dfba_configurator.py.
Replace the output/*.{svg,xml,mat,txt} and output/cells.csv rules with output*/ so that the
folders written by the sample projects (output, output_pfba, output_motility,
output_motility_prolif, ...) are ignored at any depth. The reference outputs under tests/
remain trackable.
…cenario

config/Ecoli_core.yaml defines the default PhysiCell_settings.xml (Figure 2). It was generated
from the XML and checked by regenerating the XML with addons/dFBA/utils/dfba_configurator.py.
The voxel-sharing XMLs have no YAML of their own; the README says so.
…t configuration

Match the grid and time steps of the other E. coli samples (ecoli_acetic_switch,
bacterial_colony): dx = dy = dz = 2 um (was 1.6 um) and diffusion, mechanics, phenotype and
intracellular dt = 0.001 min (were 0.01, 0.1, 6 and 0.01 min). The 16 x 16 x 16 um domain,
and so the analytical prediction in the notebook, is unchanged. Cell counts are identical
to the previous settings; dry biomass at 4 h differs by 2.2%.

- Ecoli_core.yaml: intracellular_dt 0.001.
- dfba_analysis.ipynb: voxel_resolution_um 2.0.
- README: state the grid and time steps.
The voxel-sharing XMLs are unchanged.
…nit_test configs

gen_dxdt_configs.py read config/Unit_test_mass_conversion.xml, which was removed because it
duplicated the default config/PhysiCell_settings.xml; it now uses the latter as its base.
gen_update_order_configs.py read config/Unit_test_voxel_sharing_mixed.xml, which moved to
config/voxel_sharing_test/; it now reads it from there (the generated configs and cell CSVs are
still written to config/). Also correct the config path in the check_voxel_nonnegative.py docstring.
…unit_test README

The project now runs four checks: mass conversion, voxel sharing, update order and thread
count, and voxel size and time step. List the new run_dxdt_test.sh command, the generator and
check scripts, the conservation-ledger header and the Python requirements (numpy and scipy;
cobra for check_dxdt.py and elemental_check.py).
…h_model

The dFBA addon now reads <secondary_objective> from inside <growth_model>; the position
directly under <intracellular> is deprecated and prints a warning (#21). PhysiCell_settings_pfba.xml
uses the new position, which is also what addons/dFBA/utils/dfba_configurator.py writes from
Ecoli_core_pfba.yaml. cancer_core_metabolism/config/PhysiCell_settings_pfba.xml already has it there.
…t default configuration

The Tests workflow (.github/workflows/tests.yml) runs the dfba_unit_test sample with
config/Unit_test_mass_conversion.xml, which was removed as a duplicate of the default
config/PhysiCell_settings.xml, so the run step failed with FileNotFoundError. Restore the file name
as an exact copy of the current default configuration.
…-and-human-template

Clean up the fba sample projects: READMEs, final configurations and dFBA YAML definitions
…* ids

- post_update_intracellular now casts to dFBAIntracellular* and loops over
  substrate_exchanges, writing both the realised flux and the applied lower
  bound (R_EX_<id>, R_EX_<id>_lb) through a safe set_custom_data() helper
  (undeclared names are warned-and-skipped instead of silently resolving to
  custom_data index 0, as the bare operator[] would do).
- custom.h includes the dFBA intracellular/model headers needed for the cast
  and for sbml_model.getReactionLowerBound().
- Removed the now-unused oxygen_flux/glucose_flux/acetate_flux/co2_flux
  custom_data declarations from PhysiCell_settings.xml and
  PhysiCell_settings_pfba.xml (the R_EX_*/R_EX_*_lb fields were already
  declared alongside them).
- plot_ecoli_figure_a.py: domain volume in 2D runs now uses the dz slab
  thickness instead of the ignored z_min/z_max range.
Same generic substrate_exchanges loop + set_custom_data helper pattern as
ecoli_acetic_switch, now also recording the applied lower bound (R_EX_*_lb).
Renamed oxygen_flux/glucose_flux/acetate_flux to R_EX_o2_e/R_EX_glc__D_e/
R_EX_ac_e (+ _lb) across all 6 PhysiCell_settings-style XML configs (main,
mass-conversion, and the 4 voxel-sharing-test configs). Updated
check_update_order.py's hardcoded column names to match.
Same generic substrate_exchanges loop + set_custom_data helper pattern as
the other use cases, now also recording the applied lower bound. Renamed
oxygen_flux/glucose_flux/lactate_flux to R_EX_o2_e/R_EX_glc_e/R_EX_lac_D_e
(+ _lb) in PhysiCell_settings.xml. No downstream scripts reference these
fields.
… R_EX_* ids

post_update_intracellular's growth_rate/oxygen_flux/glucose_flux/acetate_flux/
co2_flux writes (including the ADDON_PHYSIDFBA death short-circuit branch)
replaced by the generic substrate_exchanges loop + set_custom_data helper,
now also recording R_EX_*_lb. Non-exchange fields (growth_factor,
metabolic_mode, atp_flux, motility_atp_flux, motility_speed_fraction) are
untouched. Removed the now-dead old-named custom_data declarations from
PhysiCell_settings_motility.xml and PhysiCell_settings_motility_proliferation.xml
(the R_EX_*/_lb entries were already declared alongside them, previously
unused). Updated fluxes_analysis.py, dynamic_analysis.py and
composite_figure.py to the R_EX_* names; dynamics_analysis.ipynb's cached
output (a stale printed column list) is left as-is and will refresh on next
run.
…* ids

post_update_intracellular_c_beijerinckii/_m_barkeri and the dispatching
post_update_intracellular are replaced by a single generic function: each
cell only has its own species' model in substrate_exchanges, so no CB_/MB_
prefix or manual cross-zeroing is needed any more (a field irrelevant to a
given cell's species is simply never written and stays at its XML default
of 0.0). Also now records R_EX_*_lb. custom.h drops the two now-removed
per-species forward declarations and gains the dFBA includes used elsewhere
(dfba_intracellular.h was already included directly in custom.cpp).

config/PhysiCell_settings.xml: both cell types' custom_data blocks rewritten
to the union of both species' exchanges (R_EX_glc_D_e, R_EX_h2_e, R_EX_nh4_e,
R_EX_pi_e, R_EX_so4_e, R_EX_ac_e, R_EX_co2_e, R_EX_ch4_e) plus matching _lb
entries, bare growth_rate and fba_infeasible (prefixes dropped).

scripts/paper_figures/config.py, lib/io.py and plots/spatial_composite.py
updated to the new bare names; io.py's resolve-by-alias lookup keeps the old
CB_*/MB_*/glucose_flux/methane_flux names as fallbacks so previously
generated output is still readable. README.md's troubleshooting note updated.
@othmya othmya closed this Oct 28, 2026
@migp11
migp11 deleted the homogenize-rex-flux-naming branch October 28, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants