diff 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
line wrap: on
line diff
--- a/COBRAxy/ras_to_bounds.py	Mon Oct 14 08:22:30 2024 +0000
+++ b/COBRAxy/ras_to_bounds.py	Mon Oct 14 08:29:08 2024 +0000
@@ -125,18 +125,17 @@
     """
     for reaction in ras_row.index:
         scaling_factor = ras_row[reaction]
-        if(scaling_factor not in [np.nan, None]):
-            lower_bound=model.reactions.get_by_id(reaction).lower_bound
-            upper_bound=model.reactions.get_by_id(reaction).upper_bound
-            valMax=float((upper_bound)*scaling_factor)
-            valMin=float((lower_bound)*scaling_factor)
-            if upper_bound!=0 and lower_bound==0:
-                model.reactions.get_by_id(reaction).upper_bound=valMax
-            if upper_bound==0 and lower_bound!=0:
-                model.reactions.get_by_id(reaction).lower_bound=valMin
-            if upper_bound!=0 and lower_bound!=0:
-                model.reactions.get_by_id(reaction).lower_bound=valMin
-                model.reactions.get_by_id(reaction).upper_bound=valMax
+        lower_bound=model.reactions.get_by_id(reaction).lower_bound
+        upper_bound=model.reactions.get_by_id(reaction).upper_bound
+        valMax=float((upper_bound)*scaling_factor)
+        valMin=float((lower_bound)*scaling_factor)
+        if upper_bound!=0 and lower_bound==0:
+            model.reactions.get_by_id(reaction).upper_bound=valMax
+        if upper_bound==0 and lower_bound!=0:
+            model.reactions.get_by_id(reaction).lower_bound=valMin
+        if upper_bound!=0 and lower_bound!=0:
+            model.reactions.get_by_id(reaction).lower_bound=valMin
+            model.reactions.get_by_id(reaction).upper_bound=valMax
     pass
 
 def process_ras_cell(cellName, ras_row, model, rxns_ids, mediumRxns_ids, output_folder):
@@ -248,6 +247,7 @@
         ras_combined = pd.concat(ras_list, axis=0)
         # Normalize the RAS values by max RAS
         ras_combined = ras_combined.div(ras_combined.max(axis=0))
+        ras_combined.dropna(axis=1, how='all', inplace=True)
         #ras_combined = ras_combined.fillna(0)
         #il ras c'è per tutti o non c'è per nessuno