Mercurial > repos > bimib > cobraxy
comparison COBRAxy/flux_simulation_beta.py @ 469:5f02f7e4ea9f draft
Uploaded
| author | luca_milaz |
|---|---|
| date | Mon, 22 Sep 2025 15:14:47 +0000 |
| parents | 73f02860f7d7 |
| children | 46901af8df7c |
comparison
equal
deleted
inserted
replaced
| 468:77ed5c696865 | 469:5f02f7e4ea9f |
|---|---|
| 43 | 43 |
| 44 parser.add_argument("-mab", "--model_and_bounds", type=str, | 44 parser.add_argument("-mab", "--model_and_bounds", type=str, |
| 45 choices=['True', 'False'], | 45 choices=['True', 'False'], |
| 46 required=True, | 46 required=True, |
| 47 help="upload mode: True for model+bounds, False for complete models") | 47 help="upload mode: True for model+bounds, False for complete models") |
| 48 | |
| 49 parser.add_argument("-ens", "--sampling_enabled", type=str, | |
| 50 choices=['True', 'False'], | |
| 51 required=True, | |
| 52 help="enable sampling: True for sampling, False for no sampling") | |
| 48 | 53 |
| 49 parser.add_argument('-ol', '--out_log', | 54 parser.add_argument('-ol', '--out_log', |
| 50 help="Output log") | 55 help="Output log") |
| 51 | 56 |
| 52 parser.add_argument('-td', '--tool_dir', | 57 parser.add_argument('-td', '--tool_dir', |
| 340 cell_name (str): Name of the cell, used to generate filenames for output. | 345 cell_name (str): Name of the cell, used to generate filenames for output. |
| 341 | 346 |
| 342 Returns: | 347 Returns: |
| 343 List[pd.DataFrame]: A list of DataFrames containing statistics and analysis results. | 348 List[pd.DataFrame]: A list of DataFrames containing statistics and analysis results. |
| 344 """ | 349 """ |
| 345 | 350 |
| 346 if ARGS.algorithm == 'OPTGP': | 351 if ARGS.sampling_enabled == "True" and ARGS.n_samples > 0: |
| 347 OPTGP_sampler(model_input, cell_name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) | 352 |
| 348 elif ARGS.algorithm == 'CBS': | 353 if ARGS.algorithm == 'OPTGP': |
| 349 CBS_sampler(model_input, cell_name, ARGS.n_samples, ARGS.n_batches, ARGS.seed) | 354 OPTGP_sampler(model_input, cell_name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) |
| 350 | 355 elif ARGS.algorithm == 'CBS': |
| 351 df_mean, df_median, df_quantiles = fluxes_statistics(cell_name, ARGS.output_types) | 356 CBS_sampler(model_input, cell_name, ARGS.n_samples, ARGS.n_batches, ARGS.seed) |
| 352 | 357 |
| 353 if("fluxes" not in ARGS.output_types): | 358 df_mean, df_median, df_quantiles = fluxes_statistics(cell_name, ARGS.output_types) |
| 354 os.remove(ARGS.output_path + "/" + cell_name + '.csv') | 359 |
| 355 | 360 if("fluxes" not in ARGS.output_types): |
| 356 returnList = [df_mean, df_median, df_quantiles] | 361 os.remove(ARGS.output_path + "/" + cell_name + '.csv') |
| 362 | |
| 363 returnList = [df_mean, df_median, df_quantiles] | |
| 357 | 364 |
| 358 df_pFBA, df_FVA, df_sensitivity = fluxes_analysis(model_input, cell_name, ARGS.output_type_analysis) | 365 df_pFBA, df_FVA, df_sensitivity = fluxes_analysis(model_input, cell_name, ARGS.output_type_analysis) |
| 359 | 366 |
| 360 if("pFBA" in ARGS.output_type_analysis): | 367 if("pFBA" in ARGS.output_type_analysis): |
| 361 returnList.append(df_pFBA) | 368 returnList.append(df_pFBA) |
| 490 ARGS.output_types = ARGS.output_type.split(",") if ARGS.output_type else [] | 497 ARGS.output_types = ARGS.output_type.split(",") if ARGS.output_type else [] |
| 491 # optional analysis output types -> list or empty | 498 # optional analysis output types -> list or empty |
| 492 ARGS.output_type_analysis = ARGS.output_type_analysis.split(",") if ARGS.output_type_analysis else [] | 499 ARGS.output_type_analysis = ARGS.output_type_analysis.split(",") if ARGS.output_type_analysis else [] |
| 493 | 500 |
| 494 # Determine if sampling should be performed | 501 # Determine if sampling should be performed |
| 495 perform_sampling = ARGS.n_samples > 0 | 502 if ARGS.sampling_enabled == "True" and ARGS.n_samples > 0: |
| 503 perform_sampling = True | |
| 496 | 504 |
| 497 print("=== INPUT FILES ===") | 505 print("=== INPUT FILES ===") |
| 498 print(f"{ARGS.input_files}") | 506 print(f"{ARGS.input_files}") |
| 499 print(f"{ARGS.file_names}") | 507 print(f"{ARGS.file_names}") |
| 500 print(f"{ARGS.output_type}") | 508 print(f"{ARGS.output_type}") |
| 558 if "quantiles" in ARGS.output_types: | 566 if "quantiles" in ARGS.output_types: |
| 559 all_quantiles = all_quantiles.fillna(0.0) | 567 all_quantiles = all_quantiles.fillna(0.0) |
| 560 all_quantiles = all_quantiles.sort_index() | 568 all_quantiles = all_quantiles.sort_index() |
| 561 write_to_file(all_quantiles.T, "quantiles", True) | 569 write_to_file(all_quantiles.T, "quantiles", True) |
| 562 else: | 570 else: |
| 563 print("=== SAMPLING SKIPPED (n_samples = 0) ===") | 571 print("=== SAMPLING SKIPPED (n_samples = 0 or sampling disabled) ===") |
| 564 | 572 |
| 565 # Handle optimization analysis outputs (always available) | 573 # Handle optimization analysis outputs (always available) |
| 566 print("=== PROCESSING OPTIMIZATION RESULTS ===") | 574 print("=== PROCESSING OPTIMIZATION RESULTS ===") |
| 567 | 575 |
| 568 # Determine the starting index for optimization results | 576 # Determine the starting index for optimization results |
