# HG changeset patch # User luca_milaz # Date 1721592835 0 # Node ID b99132184156794b366e724d983b42409274367c # Parent 8d50cf0c3d5f2366e579eadc4086a8575c5f966e Uploaded diff -r 8d50cf0c3d5f -r b99132184156 marea_2/ras_to_bounds.py --- a/marea_2/ras_to_bounds.py Sun Jul 21 20:08:46 2024 +0000 +++ b/marea_2/ras_to_bounds.py Sun Jul 21 20:13:55 2024 +0000 @@ -112,10 +112,11 @@ model_new.reactions.get_by_id(reaction).lower_bound=float(df_FVA.loc[reaction,"minimum"]) model_new.reactions.get_by_id(reaction).upper_bound=float(df_FVA.loc[reaction,"maximum"]) - for cellName, ras in ras.iterrows(): - if(ras is not None): + if(ras is not None): + for cellName, ras in ras.iterrows(): for reaction in rxns_ids: if (reaction in ras.keys() and ras[reaction] != None): + utils.logWarning(ras[reaction], ARGS.out_log) lower_bound=model_new.reactions.get_by_id(reaction).lower_bound upper_bound=model_new.reactions.get_by_id(reaction).upper_bound valMax=float((upper_bound)*ras[reaction]) @@ -127,23 +128,24 @@ if upper_bound!=0 and lower_bound!=0: model_new.reactions.get_by_id(reaction).lower_bound=valMin model_new.reactions.get_by_id(reaction).upper_bound=valMax - else: - for reaction in rxns_ids: - lower_bound=model_new.reactions.get_by_id(reaction).lower_bound - upper_bound=model_new.reactions.get_by_id(reaction).upper_bound - valMax = float((upper_bound)*1) - valMin=float((lower_bound)*1) - if upper_bound!=0 and lower_bound==0: - model_new.reactions.get_by_id(reaction).upper_bound=valMax - if upper_bound==0 and lower_bound!=0: - model_new.reactions.get_by_id(reaction).lower_bound=valMin - if upper_bound!=0 and lower_bound!=0: - model_new.reactions.get_by_id(reaction).lower_bound=valMin - model_new.reactions.get_by_id(reaction).upper_bound=valMax - bounds = pd.DataFrame(columns = ["lower_bound", "upper_bound"], index=rxns_ids) - for reaction in model.reactions: - bounds.loc[reaction.id] = [reaction.lower_bound, reaction.upper_bound] - bounds.to_csv(ARGS.output_folder + cellName, sep = '\t', index = False) + else: + for reaction in rxns_ids: + lower_bound=model_new.reactions.get_by_id(reaction).lower_bound + upper_bound=model_new.reactions.get_by_id(reaction).upper_bound + valMax = float((upper_bound)*1) + valMin=float((lower_bound)*1) + if upper_bound!=0 and lower_bound==0: + model_new.reactions.get_by_id(reaction).upper_bound=valMax + if upper_bound==0 and lower_bound!=0: + model_new.reactions.get_by_id(reaction).lower_bound=valMin + if upper_bound!=0 and lower_bound!=0: + model_new.reactions.get_by_id(reaction).lower_bound=valMin + model_new.reactions.get_by_id(reaction).upper_bound=valMax + + bounds = pd.DataFrame(columns = ["lower_bound", "upper_bound"], index=rxns_ids) + for reaction in model.reactions: + bounds.loc[reaction.id] = [reaction.lower_bound, reaction.upper_bound] + bounds.to_csv(ARGS.output_folder + cellName, sep = '\t', index = False) pass