# HG changeset patch # User luca_milaz # Date 1758554087 0 # Node ID 5f02f7e4ea9fe7ca71267b2ae5b360ba33e1ca36 # Parent 77ed5c6968653c3840836324d4b3ef9b0cabd0d2 Uploaded diff -r 77ed5c696865 -r 5f02f7e4ea9f COBRAxy/flux_simulation_beta.py --- a/COBRAxy/flux_simulation_beta.py Mon Sep 22 15:14:26 2025 +0000 +++ b/COBRAxy/flux_simulation_beta.py Mon Sep 22 15:14:47 2025 +0000 @@ -46,6 +46,11 @@ required=True, help="upload mode: True for model+bounds, False for complete models") + parser.add_argument("-ens", "--sampling_enabled", type=str, + choices=['True', 'False'], + required=True, + help="enable sampling: True for sampling, False for no sampling") + parser.add_argument('-ol', '--out_log', help="Output log") @@ -342,18 +347,20 @@ Returns: List[pd.DataFrame]: A list of DataFrames containing statistics and analysis results. """ - - if ARGS.algorithm == 'OPTGP': - OPTGP_sampler(model_input, cell_name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) - elif ARGS.algorithm == 'CBS': - CBS_sampler(model_input, cell_name, ARGS.n_samples, ARGS.n_batches, ARGS.seed) - df_mean, df_median, df_quantiles = fluxes_statistics(cell_name, ARGS.output_types) + if ARGS.sampling_enabled == "True" and ARGS.n_samples > 0: + + if ARGS.algorithm == 'OPTGP': + OPTGP_sampler(model_input, cell_name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) + elif ARGS.algorithm == 'CBS': + CBS_sampler(model_input, cell_name, ARGS.n_samples, ARGS.n_batches, ARGS.seed) - if("fluxes" not in ARGS.output_types): - os.remove(ARGS.output_path + "/" + cell_name + '.csv') + df_mean, df_median, df_quantiles = fluxes_statistics(cell_name, ARGS.output_types) - returnList = [df_mean, df_median, df_quantiles] + if("fluxes" not in ARGS.output_types): + os.remove(ARGS.output_path + "/" + cell_name + '.csv') + + returnList = [df_mean, df_median, df_quantiles] df_pFBA, df_FVA, df_sensitivity = fluxes_analysis(model_input, cell_name, ARGS.output_type_analysis) @@ -492,7 +499,8 @@ ARGS.output_type_analysis = ARGS.output_type_analysis.split(",") if ARGS.output_type_analysis else [] # Determine if sampling should be performed - perform_sampling = ARGS.n_samples > 0 + if ARGS.sampling_enabled == "True" and ARGS.n_samples > 0: + perform_sampling = True print("=== INPUT FILES ===") print(f"{ARGS.input_files}") @@ -560,7 +568,7 @@ all_quantiles = all_quantiles.sort_index() write_to_file(all_quantiles.T, "quantiles", True) else: - print("=== SAMPLING SKIPPED (n_samples = 0) ===") + print("=== SAMPLING SKIPPED (n_samples = 0 or sampling disabled) ===") # Handle optimization analysis outputs (always available) print("=== PROCESSING OPTIMIZATION RESULTS ===")