comparison COBRAxy/ras_to_bounds.py @ 222:4c0bb0186d38 draft

Uploaded
author luca_milaz
date Sat, 14 Dec 2024 19:07:05 +0000
parents d0e2251fe8a6
children c2ce7d75fceb
comparison
equal deleted inserted replaced
221:d0e2251fe8a6 222:4c0bb0186d38
127 new_bounds (pd.DataFrame): integrated bounds. 127 new_bounds (pd.DataFrame): integrated bounds.
128 """ 128 """
129 new_bounds = bounds.copy() 129 new_bounds = bounds.copy()
130 for reaction in ras_row.index: 130 for reaction in ras_row.index:
131 scaling_factor = ras_row[reaction] 131 scaling_factor = ras_row[reaction]
132 lower_bound=bounds.loc[reaction, "lower_bound"] 132 if not np.isnan(scaling_factor):
133 upper_bound=bounds.loc[reaction, "upper_bound"] 133 lower_bound=bounds.loc[reaction, "lower_bound"]
134 valMax=float((upper_bound)*scaling_factor) 134 upper_bound=bounds.loc[reaction, "upper_bound"]
135 valMin=float((lower_bound)*scaling_factor) 135 valMax=float((upper_bound)*scaling_factor)
136 if np.isnan(scaling_factor): 136 valMin=float((lower_bound)*scaling_factor)
137 warning(f"scaling_factor values for {reaction}is None") 137 if upper_bound!=0 and lower_bound==0:
138 if upper_bound!=0 and lower_bound==0: 138 new_bounds.loc[reaction, "upper_bound"] = valMax
139 new_bounds.loc[reaction, "upper_bound"] = valMax 139 if upper_bound==0 and lower_bound!=0:
140 if upper_bound==0 and lower_bound!=0: 140 new_bounds.loc[reaction, "lower_bound"] = valMin
141 new_bounds.loc[reaction, "lower_bound"] = valMin 141 if upper_bound!=0 and lower_bound!=0:
142 if upper_bound!=0 and lower_bound!=0: 142 new_bounds.loc[reaction, "lower_bound"] = valMin
143 new_bounds.loc[reaction, "lower_bound"] = valMin 143 new_bounds.loc[reaction, "upper_bound"] = valMax
144 new_bounds.loc[reaction, "upper_bound"] = valMax
145 return new_bounds 144 return new_bounds
146 145
147 def process_ras_cell(cellName, ras_row, model, rxns_ids, output_folder): 146 def process_ras_cell(cellName, ras_row, model, rxns_ids, output_folder):
148 """ 147 """
149 Process a single RAS cell, apply bounds, and save the bounds to a CSV file. 148 Process a single RAS cell, apply bounds, and save the bounds to a CSV file.