Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_to_bounds.py @ 219:264a10b57481 draft
Uploaded
author | luca_milaz |
---|---|
date | Sat, 14 Dec 2024 18:56:53 +0000 |
parents | 8d1988935e1f |
children | fa5483499199 |
comparison
equal
deleted
inserted
replaced
218:8d1988935e1f | 219:264a10b57481 |
---|---|
131 scaling_factor = ras_row[reaction] | 131 scaling_factor = ras_row[reaction] |
132 lower_bound=bounds.loc[reaction, "lower_bound"] | 132 lower_bound=bounds.loc[reaction, "lower_bound"] |
133 upper_bound=bounds.loc[reaction, "upper_bound"] | 133 upper_bound=bounds.loc[reaction, "upper_bound"] |
134 valMax=float((upper_bound)*scaling_factor) | 134 valMax=float((upper_bound)*scaling_factor) |
135 valMin=float((lower_bound)*scaling_factor) | 135 valMin=float((lower_bound)*scaling_factor) |
136 if(valMax is None or valMin is None): | |
137 warning(f"RAS values for {reaction}is None") | |
136 if upper_bound!=0 and lower_bound==0: | 138 if upper_bound!=0 and lower_bound==0: |
137 new_bounds.loc[reaction, "upper_bound"] = valMax | 139 new_bounds.loc[reaction, "upper_bound"] = valMax |
138 if upper_bound==0 and lower_bound!=0: | 140 if upper_bound==0 and lower_bound!=0: |
139 new_bounds.loc[reaction, "lower_bound"] = valMin | 141 new_bounds.loc[reaction, "lower_bound"] = valMin |
140 if upper_bound!=0 and lower_bound!=0: | 142 if upper_bound!=0 and lower_bound!=0: |
158 """ | 160 """ |
159 bounds = pd.DataFrame([(rxn.lower_bound, rxn.upper_bound) for rxn in model.reactions], index=rxns_ids, columns=["lower_bound", "upper_bound"]) | 161 bounds = pd.DataFrame([(rxn.lower_bound, rxn.upper_bound) for rxn in model.reactions], index=rxns_ids, columns=["lower_bound", "upper_bound"]) |
160 new_bounds = apply_ras_bounds(bounds, ras_row) | 162 new_bounds = apply_ras_bounds(bounds, ras_row) |
161 if new_bounds.isnull().values.any(): | 163 if new_bounds.isnull().values.any(): |
162 warning(f"RAS values for {cellName} contain NaN values. Skipping this cell.") | 164 warning(f"RAS values for {cellName} contain NaN values. Skipping this cell.") |
165 return | |
163 new_bounds.to_csv(output_folder + cellName + ".csv", sep='\t', index=True) | 166 new_bounds.to_csv(output_folder + cellName + ".csv", sep='\t', index=True) |
164 pass | 167 pass |
165 | 168 |
166 def generate_bounds(model: cobra.Model, medium: dict, ras=None, output_folder='output/') -> pd.DataFrame: | 169 def generate_bounds(model: cobra.Model, medium: dict, ras=None, output_folder='output/') -> pd.DataFrame: |
167 """ | 170 """ |