Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_to_bounds.py @ 107:58919e82d96e draft
Uploaded
author | luca_milaz |
---|---|
date | Sun, 13 Oct 2024 14:06:53 +0000 |
parents | 1629671d4ca6 |
children | 22cebbdb4b6d |
comparison
equal
deleted
inserted
replaced
106:1629671d4ca6 | 107:58919e82d96e |
---|---|
183 if(reaction == "EX_lac__L_e"): | 183 if(reaction == "EX_lac__L_e"): |
184 model2.reactions.get_by_id(reaction).lower_bound=float(0.0) | 184 model2.reactions.get_by_id(reaction).lower_bound=float(0.0) |
185 ''' | 185 ''' |
186 for reaction, value in medium.items(): | 186 for reaction, value in medium.items(): |
187 if value is not None: | 187 if value is not None: |
188 model.reactions.get_by_id(reaction).lower_bound = -float(value) | 188 if(reaction != "EX_thbpt_e" and reaction != "EX_lac__L_e"): |
189 model.reactions.get_by_id(reaction).lower_bound = -float(value) | |
190 if(reaction == "EX_lac__L_e"): | |
191 model.reactions.get_by_id(reaction).lower_bound = float(0.0) | |
192 | |
189 | 193 |
190 # Perform Flux Variability Analysis (FVA) | 194 # Perform Flux Variability Analysis (FVA) |
191 df_FVA = cobra.flux_analysis.flux_variability_analysis(model, fraction_of_optimum=0, processes=1).round(8) | 195 df_FVA = cobra.flux_analysis.flux_variability_analysis(model, fraction_of_optimum=0, processes=1).round(8) |
192 | 196 |
193 # Set FVA bounds | 197 # Set FVA bounds |
197 | 201 |
198 if ras is not None: | 202 if ras is not None: |
199 #Parallel(n_jobs=cpu_count())(delayed(process_ras_cell)(cellName, ras_row, model, rxns_ids, output_folder) for cellName, ras_row in ras.iterrows()) | 203 #Parallel(n_jobs=cpu_count())(delayed(process_ras_cell)(cellName, ras_row, model, rxns_ids, output_folder) for cellName, ras_row in ras.iterrows()) |
200 for cellName, ras_row in ras.iterrows(): | 204 for cellName, ras_row in ras.iterrows(): |
201 process_ras_cell(cellName, ras_row, model, rxns_ids, output_folder) | 205 process_ras_cell(cellName, ras_row, model, rxns_ids, output_folder) |
202 break | 206 break #just one cell for testing |
203 else: | 207 else: |
204 model_new = model.copy() | 208 model_new = model.copy() |
205 apply_ras_bounds(model_new, pd.Series([1]*len(rxns_ids), index=rxns_ids), rxns_ids) | 209 apply_ras_bounds(model_new, pd.Series([1]*len(rxns_ids), index=rxns_ids), rxns_ids) |
206 bounds = pd.DataFrame([(rxn.lower_bound, rxn.upper_bound) for rxn in model_new.reactions], index=rxns_ids, columns=["lower_bound", "upper_bound"]) | 210 bounds = pd.DataFrame([(rxn.lower_bound, rxn.upper_bound) for rxn in model_new.reactions], index=rxns_ids, columns=["lower_bound", "upper_bound"]) |
207 bounds.to_csv(output_folder + "bounds.csv", sep='\t', index=True) | 211 bounds.to_csv(output_folder + "bounds.csv", sep='\t', index=True) |