# HG changeset patch # User luca_milaz # Date 1729017094 0 # Node ID 03bbbd9af67d1dd543049cdec257a3db1d3d26d0 # Parent dfb6a1dc6dbc247d17ab651f7a06ae22336532ed Uploaded diff -r dfb6a1dc6dbc -r 03bbbd9af67d COBRAxy/ras_to_bounds.py --- 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]