diff --git a/docs/inputting.md b/docs/inputting.md index b15464f9..01d1f1e5 100644 --- a/docs/inputting.md +++ b/docs/inputting.md @@ -31,8 +31,7 @@ The file `config.toml` **must** contain these top-level fields: The following optional fields can also be specified: -* `reject_non_steady` Boolean saying whether to reject draws that enter non-steady states -* `penalize_non_steady` Boolean saying whether to penalize steady state deviations in the likelihood. It cannot be `True` when `reject_non_steady` is `True`. +* `penalize_non_steady` Boolean saying whether to penalize steady state deviations in the likelihood. * `ode_solver_config` Table of configuration options for Stan's ode solver * `algebra_solver_config` Table of configuration options for Stan's algebra solver * `cmdstanpy_config` Table of keyword arguments to the cmdstanpy method [`CmdStanModel.sample](https://cmdstanpy.readthedocs.io/en/v1.1.0/api.html#cmdstanpy.CmdStanModel.sample) diff --git a/maud/data/example_inputs/linear/expected_stan_input.json b/maud/data/example_inputs/linear/expected_stan_input.json index f08ca74e..b38103f3 100644 --- a/maud/data/example_inputs/linear/expected_stan_input.json +++ b/maud/data/example_inputs/linear/expected_stan_input.json @@ -1 +1 @@ -{"N_mic": 4, "N_edge_sub": 3, "N_edge_prod": 3, "N_edge": 3, "N_unbalanced": 2, "N_enzyme": 3, "N_phosphorylation": 0, "N_pme": 0, "N_competitive_inhibition": 1, "N_allostery": 2, "N_allosteric_enzyme": 2, "N_drain": 0, "N_km": 5, "N_sub_km": 3, "N_prod_km": 2, "S": [[-1, 0, 0], [1, -1, 0], [0, 1, -1], [0, 0, 1]], "N_reaction": 3, "N_metabolite": 2, "balanced_mic_ix": [2, 3], "unbalanced_mic_ix": [1, 4], "ci_mic_ix": [2], "edge_type": [1, 2, 1], "edge_to_enzyme": [1, 2, 3], "edge_to_tc": [1, 2, 0], "edge_to_drain": [0, 0, 0], "edge_to_reaction": [1, 2, 3], "water_stoichiometry": [0.0, 0.0, 0.0], "transported_charge": [0.0, 0.0, 1.0], "mic_to_met": [1, 1, 2, 2], "subunits": [1, 1, 1], "sub_by_edge_long": [1, 2, 3], "sub_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_by_edge_long": [2, 3, 4], "prod_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "sub_km_ix_by_edge_long": [1, 3, 4], "sub_km_ix_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_km_ix_by_edge_long": [2, 5], "prod_km_ix_by_edge_bounds": [[1, 1], [2, 1], [2, 2]], "ci_ix_long": [1], "ci_ix_bounds": [[1, 0], [1, 1], [2, 1]], "allostery_ix_long": [1, 2], "allostery_ix_bounds": [[1, 1], [2, 2], [3, 2]], "allostery_type": [1, 2], "allostery_mic": [3, 2], "phosphorylation_ix_long": [], "phosphorylation_ix_bounds": [[1, 0], [1, 0], [1, 0]], "phosphorylation_type": [], "phosphorylation_pme": [], "priors_km": [[0.0, 0.0, 0.0, 0.0, 0.0], [0.6, 0.6, 0.6, 0.6, 0.6]], "priors_ki": [[0.0], [0.6]], "priors_kcat": [[0.0, 0.0, 0.0], [0.6, 0.6, 0.6]], "priors_dissociation_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_transfer_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_kcat_pme": [[], []], "priors_drain_train": [[[]], [[]]], "priors_conc_enzyme_train": [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]], [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]], "priors_conc_unbalanced_train": [[[-2.3, -2.3], [-2.3, -2.3]], [[2.0, 2.0], [2.0, 2.0]]], "priors_conc_pme_train": [[[]], [[]]], "priors_psi_train": [[-0.95, -0.95], [0.2, 0.2]], "prior_loc_dgf": [-1.0, -2.0], "prior_cov_dgf": [[0.05, 0.0], [0.0, 0.05]], "N_experiment_train": 2, "N_flux_measurement_train": 2, "N_enzyme_measurement_train": 6, "N_conc_measurement_train": 7, "N_enzyme_knockout_train": 0, "N_pme_knockout_train": 0, "temperature_train": [299.0, 298.15], "enzyme_knockout_train_long": [], "enzyme_knockout_train_bounds": [[1, 0], [1, 0]], "pme_knockout_train_long": [], "pme_knockout_train_bounds": [[1, 0], [1, 0]], "yconc_train": [0.59, 1.09, 1.05, 0.54, 0.38, 1.12, 1.14], "sigma_yconc_train": [0.1, 0.05, 0.05, 0.1, 0.1, 0.05, 0.05], "experiment_yconc_train": [1, 1, 1, 2, 2, 2, 2], "mic_ix_yconc_train": [2, 1, 4, 2, 3, 1, 4], "yflux_train": [0.19, 0.39], "sigma_yflux_train": [0.1, 0.1], "experiment_yflux_train": [1, 2], "reaction_yflux_train": [3, 3], "yenz_train": [1.5, 1.5, 1.5, 1.5, 1.5, 1.5], "sigma_yenz_train": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], "experiment_yenz_train": [1, 1, 1, 2, 2, 2], "enzyme_yenz_train": [1, 2, 3, 1, 2, 3], "likelihood": 1, "drain_small_conc_corrector": 1e-06, "reject_non_steady": 1, "penalize_non_steady": 0, "steady_state_threshold_abs": 1e-06, "steady_state_threshold_rel": 0.001, "steady_state_penalty_rel": 1e-08, "rel_tol_ode": 1e-07, "abs_tol_ode": 1e-07, "max_num_steps_ode": 1000000, "rel_tol_alg": 1e-05, "abs_tol_alg": 1e-05, "max_num_steps_alg": 1000000, "conc_init": [[0.59, 0.38], [0.54, 0.38]]} +{"N_mic": 4, "N_edge_sub": 3, "N_edge_prod": 3, "N_edge": 3, "N_unbalanced": 2, "N_enzyme": 3, "N_phosphorylation": 0, "N_pme": 0, "N_competitive_inhibition": 1, "N_allostery": 2, "N_allosteric_enzyme": 2, "N_drain": 0, "N_km": 5, "N_sub_km": 3, "N_prod_km": 2, "S": [[-1, 0, 0], [1, -1, 0], [0, 1, -1], [0, 0, 1]], "N_reaction": 3, "N_metabolite": 2, "balanced_mic_ix": [2, 3], "unbalanced_mic_ix": [1, 4], "ci_mic_ix": [2], "edge_type": [1, 2, 1], "edge_to_enzyme": [1, 2, 3], "edge_to_tc": [1, 2, 0], "edge_to_drain": [0, 0, 0], "edge_to_reaction": [1, 2, 3], "water_stoichiometry": [0.0, 0.0, 0.0], "transported_charge": [0.0, 0.0, 1.0], "mic_to_met": [1, 1, 2, 2], "subunits": [1, 1, 1], "sub_by_edge_long": [1, 2, 3], "sub_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_by_edge_long": [2, 3, 4], "prod_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "sub_km_ix_by_edge_long": [1, 3, 4], "sub_km_ix_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_km_ix_by_edge_long": [2, 5], "prod_km_ix_by_edge_bounds": [[1, 1], [2, 1], [2, 2]], "ci_ix_long": [1], "ci_ix_bounds": [[1, 0], [1, 1], [2, 1]], "allostery_ix_long": [1, 2], "allostery_ix_bounds": [[1, 1], [2, 2], [3, 2]], "allostery_type": [1, 2], "allostery_mic": [3, 2], "phosphorylation_ix_long": [], "phosphorylation_ix_bounds": [[1, 0], [1, 0], [1, 0]], "phosphorylation_type": [], "phosphorylation_pme": [], "priors_km": [[0.0, 0.0, 0.0, 0.0, 0.0], [0.6, 0.6, 0.6, 0.6, 0.6]], "priors_ki": [[0.0], [0.6]], "priors_kcat": [[0.0, 0.0, 0.0], [0.6, 0.6, 0.6]], "priors_dissociation_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_transfer_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_kcat_pme": [[], []], "priors_drain_train": [[[]], [[]]], "priors_conc_enzyme_train": [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]], [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]], "priors_conc_unbalanced_train": [[[-2.3, -2.3], [-2.3, -2.3]], [[2.0, 2.0], [2.0, 2.0]]], "priors_conc_pme_train": [[[]], [[]]], "priors_psi_train": [[-0.95, -0.95], [0.2, 0.2]], "prior_loc_dgf": [-1.0, -2.0], "prior_cov_dgf": [[0.05, 0.0], [0.0, 0.05]], "N_experiment_train": 2, "N_flux_measurement_train": 2, "N_enzyme_measurement_train": 6, "N_conc_measurement_train": 7, "N_enzyme_knockout_train": 0, "N_pme_knockout_train": 0, "temperature_train": [299.0, 298.15], "enzyme_knockout_train_long": [], "enzyme_knockout_train_bounds": [[1, 0], [1, 0]], "pme_knockout_train_long": [], "pme_knockout_train_bounds": [[1, 0], [1, 0]], "yconc_train": [0.59, 1.09, 1.05, 0.54, 0.38, 1.12, 1.14], "sigma_yconc_train": [0.1, 0.05, 0.05, 0.1, 0.1, 0.05, 0.05], "experiment_yconc_train": [1, 1, 1, 2, 2, 2, 2], "mic_ix_yconc_train": [2, 1, 4, 2, 3, 1, 4], "yflux_train": [0.19, 0.39], "sigma_yflux_train": [0.1, 0.1], "experiment_yflux_train": [1, 2], "reaction_yflux_train": [3, 3], "yenz_train": [1.5, 1.5, 1.5, 1.5, 1.5, 1.5], "sigma_yenz_train": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], "experiment_yenz_train": [1, 1, 1, 2, 2, 2], "enzyme_yenz_train": [1, 2, 3, 1, 2, 3], "likelihood": 1, "drain_small_conc_corrector": 1e-06, "penalize_non_steady": 0, "steady_state_threshold_abs": 1e-06, "steady_state_threshold_rel": 0.001, "steady_state_penalty_rel": 1e-08, "rel_tol_ode": 1e-07, "abs_tol_ode": 1e-07, "max_num_steps_ode": 1000000, "rel_tol_alg": 1e-05, "abs_tol_alg": 1e-05, "max_num_steps_alg": 1000000, "conc_init": [[0.59, 0.38], [0.54, 0.38]]} diff --git a/maud/data/example_inputs/methionine/config.toml b/maud/data/example_inputs/methionine/config.toml index 7ec0eda4..994b60d3 100644 --- a/maud/data/example_inputs/methionine/config.toml +++ b/maud/data/example_inputs/methionine/config.toml @@ -4,7 +4,6 @@ priors_file = "priors.toml" experiments_file = "experiments.toml" user_inits_file = "inits.toml" likelihood = true -reject_non_steady = true [cmdstanpy_config] iter_warmup = 1000 diff --git a/maud/data_model/maud_config.py b/maud/data_model/maud_config.py index 18e283bb..22a85052 100644 --- a/maud/data_model/maud_config.py +++ b/maud/data_model/maud_config.py @@ -2,7 +2,7 @@ from typing import Optional -from pydantic import BaseModel, ConfigDict, Field, model_validator +from pydantic import BaseModel, ConfigDict, Field class ODESolverConfig(BaseModel): @@ -32,7 +32,6 @@ class MaudConfig(BaseModel): :param experiments_file: path to a valid experiments file. :param likelihood: Whether or not to take measurements into account. :param cmdstanpy_config: Arguments to cmdstanpy.CmdStanModel.sample. - :param reject_non_steady: Reject draws if a non-steady state is encountered. :param penalize_non_steady: Penalize the deviation from steady state in the log likelihood. :param ode_solver_config: Configuration for Stan's ode solver. :param algebra_solver_config: Configuration for Stan's algebra solver. @@ -67,7 +66,6 @@ class MaudConfig(BaseModel): algebra_solver_config: AlgebraSolverConfig = Field( default_factory=AlgebraSolverConfig ) - reject_non_steady: bool = True penalize_non_steady: bool = False steady_state_threshold_abs: float = 1e-8 steady_state_threshold_rel: float = 1e-3 @@ -76,12 +74,3 @@ class MaudConfig(BaseModel): drain_small_conc_corrector: float = 1e-6 molecule_unit: str = "mmol" volume_unit: str = "L" - - @model_validator(mode="after") - def do_not_penalize_if_rejecting(self): - """Check that locations are non-null.""" - assert not self.penalize_non_steady and self.reject_non_steady, ( - "Penalizing the non-steady state has no effect if the non-steady" - " state is rejected; set one of the two to false." - ) - return self diff --git a/maud/getting_stan_inputs.py b/maud/getting_stan_inputs.py index 008225b3..41d10339 100644 --- a/maud/getting_stan_inputs.py +++ b/maud/getting_stan_inputs.py @@ -465,7 +465,6 @@ def get_config_input(config: MaudConfig): return { "likelihood": int(config.likelihood), "drain_small_conc_corrector": config.drain_small_conc_corrector, - "reject_non_steady": int(config.reject_non_steady), "penalize_non_steady": int(config.penalize_non_steady), "steady_state_threshold_abs": config.steady_state_threshold_abs, "steady_state_threshold_rel": config.steady_state_threshold_rel, diff --git a/maud/stan/model.stan b/maud/stan/model.stan index 9ca60e4e..6df77c45 100644 --- a/maud/stan/model.stan +++ b/maud/stan/model.stan @@ -101,7 +101,6 @@ data { real steady_state_penalty_rel; int likelihood; // set to 0 for priors-only mode real drain_small_conc_corrector; - int reject_non_steady; int penalize_non_steady; } transformed data {