Mercurial > repos > bimib > marea_2
changeset 189:0eca2d3b7509 draft
Uploaded
author | luca_milaz |
---|---|
date | Tue, 30 Jul 2024 20:08:44 +0000 |
parents | 3e711b9fa866 |
children | c1bf1291390f |
files | marea_2/flux_simulation.py |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/marea_2/flux_simulation.py Tue Jul 30 20:08:31 2024 +0000 +++ b/marea_2/flux_simulation.py Tue Jul 30 20:08:44 2024 +0000 @@ -36,14 +36,18 @@ required = True, type=str, help = 'inputs bounds') + + parser.add_argument('-ni', '--names', + required = True, + type=str, + help = 'cell names') parser.add_argument( '-ms', '--model_selector', type = utils.Model, default = utils.Model.ENGRO2, choices = [utils.Model.ENGRO2, utils.Model.Custom], help = 'chose which type of model you want use') - parser.add_argument("-mo", "--model", type = str, - help = "path to input file with custom rules, if provided") + parser.add_argument("-mo", "--model", type = str) parser.add_argument("-mn", "--model_name", type = str, help = "custom mode name") @@ -182,19 +186,15 @@ pass -def model_sampler(model_input:cobra.Model, model_name:str)-> List[pd.DataFrame]: +def model_sampler(model_input_original:cobra.Model, bounds_path:str, cell_name:str)-> List[pd.DataFrame]: - - bounds_df = read_dataset(model_name, "bounds dataset") + model_input = model_input_original.copy() + bounds_df = read_dataset(bounds_path, "bounds dataset") for rxn_index, row in bounds_df.iterrows(): model_input.reactions.get_by_id(rxn_index).lower_bound = row.lower_bound model_input.reactions.get_by_id(rxn_index).upper_bound = row.upper_bound - - utils.logWarning( - "Sampling model: " + model_name, - ARGS.out_log) - name = model_name.split('.')[0] + name = cell_name.split('.')[0] if ARGS.algorithm == 'OPTGP': OPTGP_sampler(model_input, name, ARGS.n_samples, ARGS.thinning, ARGS.n_batches, ARGS.seed) @@ -210,7 +210,7 @@ returnList = [] returnList.append(df_mean, df_median, df_quantiles) - df_pFBA, df_FVA, df_sensitivity = fluxes_analysis(name, model_name, ARGS.output_type_analysis) + df_pFBA, df_FVA, df_sensitivity = fluxes_analysis(model_input, name, ARGS.output_type_analysis) if("pFBA" in ARGS.output_type_analysis): returnList.append(df_pFBA) @@ -325,11 +325,12 @@ model = model_type.getCOBRAmodel(toolDir=ARGS.tool_dir) ARGS.bounds = ARGS.input.split(",") + ARGS.bounds_name = ARGS.names.split(",") ARGS.output_types = ARGS.output_type.split(",") ARGS.output_type_analysis = ARGS.output_type_analysis.split(",") - results = Parallel(n_jobs=num_processors)(delayed(model_sampler)(model, model_name) for model_name in ARGS.bounds) + results = Parallel(n_jobs=num_processors)(delayed(model_sampler)(model, bounds_path, cell_name) for bounds_path, cell_name in zip(ARGS.bounds, ARGS.bounds_name)) all_mean = pd.concat([result[0] for result in results], ignore_index=False) all_median = pd.concat([result[1] for result in results], ignore_index=False)