Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_to_bounds.py @ 122:7e1ce04cf192 draft
Uploaded
author | luca_milaz |
---|---|
date | Mon, 14 Oct 2024 08:22:30 +0000 |
parents | 567ffd4333d4 |
children | 258ff4208e52 |
comparison
equal
deleted
inserted
replaced
121:2121cc1aef45 | 122:7e1ce04cf192 |
---|---|
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 for reaction in rxns_ids: | 126 for reaction in ras_row.index: |
127 if reaction in ras_row.index and reaction not in mediumRxns_ids: | 127 scaling_factor = ras_row[reaction] |
128 scaling_factor = ras_row[reaction] | 128 if(scaling_factor not in [np.nan, None]): |
129 lower_bound=model.reactions.get_by_id(reaction).lower_bound | 129 lower_bound=model.reactions.get_by_id(reaction).lower_bound |
130 upper_bound=model.reactions.get_by_id(reaction).upper_bound | 130 upper_bound=model.reactions.get_by_id(reaction).upper_bound |
131 valMax=float((upper_bound)*scaling_factor) | 131 valMax=float((upper_bound)*scaling_factor) |
132 valMin=float((lower_bound)*scaling_factor) | 132 valMin=float((lower_bound)*scaling_factor) |
133 if upper_bound!=0 and lower_bound==0: | 133 if upper_bound!=0 and lower_bound==0: |
176 rxns_ids = [rxn.id for rxn in model.reactions] | 176 rxns_ids = [rxn.id for rxn in model.reactions] |
177 | 177 |
178 # Set medium conditions | 178 # Set medium conditions |
179 for reaction, value in medium.items(): | 179 for reaction, value in medium.items(): |
180 if value is not None: | 180 if value is not None: |
181 ## SOLO ENGRO2 | |
181 if(reaction != "EX_thbpt_e" and reaction != "EX_lac__L_e"): | 182 if(reaction != "EX_thbpt_e" and reaction != "EX_lac__L_e"): |
182 model.reactions.get_by_id(reaction).lower_bound = -float(value) | 183 model.reactions.get_by_id(reaction).lower_bound = -float(value) |
183 if(reaction == "EX_lac__L_e"): | 184 if(reaction == "EX_lac__L_e"): |
184 model.reactions.get_by_id(reaction).lower_bound = float(0.0) | 185 model.reactions.get_by_id(reaction).lower_bound = float(0.0) |
185 | 186 |
245 | 246 |
246 # Concatenate all ras DataFrames into a single DataFrame | 247 # Concatenate all ras DataFrames into a single DataFrame |
247 ras_combined = pd.concat(ras_list, axis=0) | 248 ras_combined = pd.concat(ras_list, axis=0) |
248 # Normalize the RAS values by max RAS | 249 # Normalize the RAS values by max RAS |
249 ras_combined = ras_combined.div(ras_combined.max(axis=0)) | 250 ras_combined = ras_combined.div(ras_combined.max(axis=0)) |
250 ras_combined = ras_combined.fillna(0) | 251 #ras_combined = ras_combined.fillna(0) |
252 #il ras c'è per tutti o non c'è per nessuno | |
251 | 253 |
252 | 254 |
253 | 255 |
254 model_type :utils.Model = ARGS.model_selector | 256 model_type :utils.Model = ARGS.model_selector |
255 if model_type is utils.Model.Custom: | 257 if model_type is utils.Model.Custom: |