Mercurial > repos > bimib > cobraxy
changeset 130:03bbbd9af67d draft
Uploaded
author | luca_milaz |
---|---|
date | Tue, 15 Oct 2024 18:31:34 +0000 |
parents | dfb6a1dc6dbc |
children | b2fe67bba4f5 |
files | COBRAxy/ras_to_bounds.py |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/COBRAxy/ras_to_bounds.py Mon Oct 14 08:51:39 2024 +0000 +++ b/COBRAxy/ras_to_bounds.py Tue Oct 15 18:31:34 2024 +0000 @@ -180,8 +180,6 @@ if value is not None: model.reactions.get_by_id(reaction).lower_bound = -float(value) - - mediumRxns_ids = medium.keys() # Perform Flux Variability Analysis (FVA) on this medium df_FVA = cobra.flux_analysis.flux_variability_analysis(model, fraction_of_optimum=0, processes=1).round(8) @@ -222,6 +220,11 @@ if(ARGS.ras_selector == True): ras_file_list = ARGS.input_ras.split(",") ras_file_names = ARGS.name.split(",") + if len(ras_file_names) != len(set(ras_file_names)): + error_message = "Duplicated file names in the uploaded RAS matrices." + warning(error_message) + raise ValueError(error_message) + pass ras_class_names = [] for file in ras_file_names: ras_class_names.append(file.split(".")[0]) @@ -233,6 +236,8 @@ ras.set_index("Reactions", drop=True, inplace=True) ras = ras.T ras = ras.astype(float) + #append class name to patient id (dataframe index) + ras.index = [f"{idx}_{ras_class_name}" for idx in ras.index] ras_list.append(ras) for patient_id in ras.index: class_assignments.loc[class_assignments.shape[0]] = [patient_id, ras_class_name]