comparison COBRAxy/ras_to_bounds.py @ 119:829ea241c3a1 draft

Uploaded
author luca_milaz
date Sun, 13 Oct 2024 16:37:47 +0000
parents 6e1a6e480969
children 567ffd4333d4
comparison
equal deleted inserted replaced
118:6e1a6e480969 119:829ea241c3a1
121 rxns_ids (list of str): List of reaction IDs to which the scaling factors will be applied. 121 rxns_ids (list of str): List of reaction IDs to which the scaling factors will be applied.
122 mediumRxns_ids (list of str): List of reaction IDs in the medium. Their RAS is set to zero, but they are already set in the model. 122 mediumRxns_ids (list of str): List of reaction IDs in the medium. Their RAS is set to zero, but they are already set in the model.
123 Returns: 123 Returns:
124 None 124 None
125 """ 125 """
126 warning(str(model.reactions.get_by_id("EX_Lcystin_e").lower_bound))
127 warning(str(model.reactions.get_by_id("EX_Lcystin_e").upper_bound))
128 for reaction in rxns_ids: 126 for reaction in rxns_ids:
129 if reaction in ras_row.index: #and reaction not in mediumRxns_ids 127 if reaction in ras_row.index: #and reaction not in mediumRxns_ids
130 scaling_factor = ras_row[reaction] 128 scaling_factor = ras_row[reaction]
131 lower_bound=model.reactions.get_by_id(reaction).lower_bound 129 lower_bound=model.reactions.get_by_id(reaction).lower_bound
132 upper_bound=model.reactions.get_by_id(reaction).upper_bound 130 upper_bound=model.reactions.get_by_id(reaction).upper_bound
137 if upper_bound==0 and lower_bound!=0: 135 if upper_bound==0 and lower_bound!=0:
138 model.reactions.get_by_id(reaction).lower_bound=valMin 136 model.reactions.get_by_id(reaction).lower_bound=valMin
139 if upper_bound!=0 and lower_bound!=0: 137 if upper_bound!=0 and lower_bound!=0:
140 model.reactions.get_by_id(reaction).lower_bound=valMin 138 model.reactions.get_by_id(reaction).lower_bound=valMin
141 model.reactions.get_by_id(reaction).upper_bound=valMax 139 model.reactions.get_by_id(reaction).upper_bound=valMax
142 warning(str(model.reactions.get_by_id("EX_Lcystin_e").lower_bound))
143 warning(str(model.reactions.get_by_id("EX_Lcystin_e").upper_bound))
144 pass 140 pass
145 141
146 def process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder): 142 def process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder):
147 """ 143 """
148 Process a single RAS cell, apply bounds, and save the bounds to a CSV file. 144 Process a single RAS cell, apply bounds, and save the bounds to a CSV file.
194 190
195 # Set FVA bounds 191 # Set FVA bounds
196 for reaction in rxns_ids: 192 for reaction in rxns_ids:
197 model.reactions.get_by_id(reaction).lower_bound = float(df_FVA.loc[reaction, "minimum"]) 193 model.reactions.get_by_id(reaction).lower_bound = float(df_FVA.loc[reaction, "minimum"])
198 model.reactions.get_by_id(reaction).upper_bound = float(df_FVA.loc[reaction, "maximum"]) 194 model.reactions.get_by_id(reaction).upper_bound = float(df_FVA.loc[reaction, "maximum"])
199
200 warning(str(model.reactions.get_by_id("EX_Lcystin_e").lower_bound))
201 warning(str(model.reactions.get_by_id("EX_Lcystin_e").upper_bound))
202 195
203 if ras is not None: 196 if ras is not None:
204 #Parallel(n_jobs=cpu_count())(delayed(process_ras_cell)(cellName, ras_row, model, rxns_ids, output_folder) for cellName, ras_row in ras.iterrows()) 197 #Parallel(n_jobs=cpu_count())(delayed(process_ras_cell)(cellName, ras_row, model, rxns_ids, output_folder) for cellName, ras_row in ras.iterrows())
205 for cellName, ras_row in ras.iterrows(): 198 for cellName, ras_row in ras.iterrows():
206 process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder) 199 process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder)