Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_to_bounds.py @ 123:258ff4208e52 draft
Uploaded
| author | luca_milaz |
|---|---|
| date | Mon, 14 Oct 2024 08:29:08 +0000 |
| parents | 7e1ce04cf192 |
| children | 67a79e4f037a |
comparison
equal
deleted
inserted
replaced
| 122:7e1ce04cf192 | 123:258ff4208e52 |
|---|---|
| 123 Returns: | 123 Returns: |
| 124 None | 124 None |
| 125 """ | 125 """ |
| 126 for reaction in ras_row.index: | 126 for reaction in ras_row.index: |
| 127 scaling_factor = ras_row[reaction] | 127 scaling_factor = ras_row[reaction] |
| 128 if(scaling_factor not in [np.nan, None]): | 128 lower_bound=model.reactions.get_by_id(reaction).lower_bound |
| 129 lower_bound=model.reactions.get_by_id(reaction).lower_bound | 129 upper_bound=model.reactions.get_by_id(reaction).upper_bound |
| 130 upper_bound=model.reactions.get_by_id(reaction).upper_bound | 130 valMax=float((upper_bound)*scaling_factor) |
| 131 valMax=float((upper_bound)*scaling_factor) | 131 valMin=float((lower_bound)*scaling_factor) |
| 132 valMin=float((lower_bound)*scaling_factor) | 132 if upper_bound!=0 and lower_bound==0: |
| 133 if upper_bound!=0 and lower_bound==0: | 133 model.reactions.get_by_id(reaction).upper_bound=valMax |
| 134 model.reactions.get_by_id(reaction).upper_bound=valMax | 134 if upper_bound==0 and lower_bound!=0: |
| 135 if upper_bound==0 and lower_bound!=0: | 135 model.reactions.get_by_id(reaction).lower_bound=valMin |
| 136 model.reactions.get_by_id(reaction).lower_bound=valMin | 136 if upper_bound!=0 and lower_bound!=0: |
| 137 if upper_bound!=0 and lower_bound!=0: | 137 model.reactions.get_by_id(reaction).lower_bound=valMin |
| 138 model.reactions.get_by_id(reaction).lower_bound=valMin | 138 model.reactions.get_by_id(reaction).upper_bound=valMax |
| 139 model.reactions.get_by_id(reaction).upper_bound=valMax | |
| 140 pass | 139 pass |
| 141 | 140 |
| 142 def process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder): | 141 def process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder): |
| 143 """ | 142 """ |
| 144 Process a single RAS cell, apply bounds, and save the bounds to a CSV file. | 143 Process a single RAS cell, apply bounds, and save the bounds to a CSV file. |
| 246 | 245 |
| 247 # Concatenate all ras DataFrames into a single DataFrame | 246 # Concatenate all ras DataFrames into a single DataFrame |
| 248 ras_combined = pd.concat(ras_list, axis=0) | 247 ras_combined = pd.concat(ras_list, axis=0) |
| 249 # Normalize the RAS values by max RAS | 248 # Normalize the RAS values by max RAS |
| 250 ras_combined = ras_combined.div(ras_combined.max(axis=0)) | 249 ras_combined = ras_combined.div(ras_combined.max(axis=0)) |
| 250 ras_combined.dropna(axis=1, how='all', inplace=True) | |
| 251 #ras_combined = ras_combined.fillna(0) | 251 #ras_combined = ras_combined.fillna(0) |
| 252 #il ras c'è per tutti o non c'è per nessuno | 252 #il ras c'è per tutti o non c'è per nessuno |
| 253 | 253 |
| 254 | 254 |
| 255 | 255 |
