# HG changeset patch # User luca_milaz # Date 1728894548 0 # Node ID 258ff4208e523d25ffb3b69fd010708e14ddc902 # Parent 7e1ce04cf192bb0f68c6e07b2891a85b41205218 Uploaded diff -r 7e1ce04cf192 -r 258ff4208e52 COBRAxy/ras_to_bounds.py --- a/COBRAxy/ras_to_bounds.py Mon Oct 14 08:22:30 2024 +0000 +++ b/COBRAxy/ras_to_bounds.py Mon Oct 14 08:29:08 2024 +0000 @@ -125,18 +125,17 @@ """ for reaction in ras_row.index: scaling_factor = ras_row[reaction] - if(scaling_factor not in [np.nan, None]): - lower_bound=model.reactions.get_by_id(reaction).lower_bound - upper_bound=model.reactions.get_by_id(reaction).upper_bound - valMax=float((upper_bound)*scaling_factor) - valMin=float((lower_bound)*scaling_factor) - if upper_bound!=0 and lower_bound==0: - model.reactions.get_by_id(reaction).upper_bound=valMax - if upper_bound==0 and lower_bound!=0: - model.reactions.get_by_id(reaction).lower_bound=valMin - if upper_bound!=0 and lower_bound!=0: - model.reactions.get_by_id(reaction).lower_bound=valMin - model.reactions.get_by_id(reaction).upper_bound=valMax + lower_bound=model.reactions.get_by_id(reaction).lower_bound + upper_bound=model.reactions.get_by_id(reaction).upper_bound + valMax=float((upper_bound)*scaling_factor) + valMin=float((lower_bound)*scaling_factor) + if upper_bound!=0 and lower_bound==0: + model.reactions.get_by_id(reaction).upper_bound=valMax + if upper_bound==0 and lower_bound!=0: + model.reactions.get_by_id(reaction).lower_bound=valMin + if upper_bound!=0 and lower_bound!=0: + model.reactions.get_by_id(reaction).lower_bound=valMin + model.reactions.get_by_id(reaction).upper_bound=valMax pass def process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder): @@ -248,6 +247,7 @@ ras_combined = pd.concat(ras_list, axis=0) # Normalize the RAS values by max RAS ras_combined = ras_combined.div(ras_combined.max(axis=0)) + ras_combined.dropna(axis=1, how='all', inplace=True) #ras_combined = ras_combined.fillna(0) #il ras c'è per tutti o non c'è per nessuno