Mercurial > repos > bimib > cobraxy
comparison COBRAxy/src/flux_simulation.py @ 548:5aef7b860706 draft default tip
Uploaded
| author | francesco_lapi |
|---|---|
| date | Tue, 28 Oct 2025 11:04:40 +0000 |
| parents | 73f2f7e2be17 |
| children |
comparison
equal
deleted
inserted
replaced
| 547:73f2f7e2be17 | 548:5aef7b860706 |
|---|---|
| 376 try: | 376 try: |
| 377 model_input.reactions.get_by_id(rxn_index).lower_bound = row.lower_bound | 377 model_input.reactions.get_by_id(rxn_index).lower_bound = row.lower_bound |
| 378 model_input.reactions.get_by_id(rxn_index).upper_bound = row.upper_bound | 378 model_input.reactions.get_by_id(rxn_index).upper_bound = row.upper_bound |
| 379 except KeyError: | 379 except KeyError: |
| 380 warning(f"Warning: Reaction {rxn_index} not found in model. Skipping.") | 380 warning(f"Warning: Reaction {rxn_index} not found in model. Skipping.") |
| 381 | 381 |
| 382 return perform_sampling_and_analysis(model_input, cell_name) | 382 return perform_sampling_and_analysis(None, cell_name, model_input=model_input) |
| 383 | 383 |
| 384 | 384 |
| 385 def perform_sampling_and_analysis(model_path: str, cell_name: str) -> List[pd.DataFrame]: | 385 def perform_sampling_and_analysis(model_path: str, cell_name: str, model_input: cobra.Model=None) -> List[pd.DataFrame]: |
| 386 """ | 386 """ |
| 387 Common function to perform sampling and analysis on a prepared model. | 387 Common function to perform sampling and analysis on a prepared model. |
| 388 | 388 |
| 389 Args: | 389 Args: |
| 390 model_path (str): Path to the tabular model file. model with bounds applied. | 390 model_path (str): Path to the tabular model file. model with bounds applied. |
| 393 Returns: | 393 Returns: |
| 394 List[pd.DataFrame]: A list of DataFrames containing statistics and analysis results. | 394 List[pd.DataFrame]: A list of DataFrames containing statistics and analysis results. |
| 395 """ | 395 """ |
| 396 | 396 |
| 397 returnList = [] | 397 returnList = [] |
| 398 | 398 |
| 399 model_input = model_utils.build_cobra_model_from_csv(model_path) | 399 if model_input is None: |
| 400 model_input = model_utils.build_cobra_model_from_csv(model_path) | |
| 400 | 401 |
| 401 if ARGS.sampling_enabled == "true": | 402 if ARGS.sampling_enabled == "true": |
| 402 | 403 |
| 403 if ARGS.algorithm == 'OPTGP': | 404 if ARGS.algorithm == 'OPTGP': |
| 404 OPTGP_sampler(model_input, cell_name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) | 405 OPTGP_sampler(model_input, cell_name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) |
