changeset 127:b99132184156 draft

Uploaded
author luca_milaz
date Sun, 21 Jul 2024 20:13:55 +0000
parents 8d50cf0c3d5f
children 32bef0ad664a
files marea_2/ras_to_bounds.py
diffstat 1 files changed, 21 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2/ras_to_bounds.py	Sun Jul 21 20:08:46 2024 +0000
+++ b/marea_2/ras_to_bounds.py	Sun Jul 21 20:13:55 2024 +0000
@@ -112,10 +112,11 @@
         model_new.reactions.get_by_id(reaction).lower_bound=float(df_FVA.loc[reaction,"minimum"])
         model_new.reactions.get_by_id(reaction).upper_bound=float(df_FVA.loc[reaction,"maximum"])
 
-    for cellName, ras in ras.iterrows():
-        if(ras is not  None):
+    if(ras is not  None):
+        for cellName, ras in ras.iterrows():
             for reaction in rxns_ids:
                 if (reaction in ras.keys() and ras[reaction] != None):
+                    utils.logWarning(ras[reaction], ARGS.out_log)
                     lower_bound=model_new.reactions.get_by_id(reaction).lower_bound
                     upper_bound=model_new.reactions.get_by_id(reaction).upper_bound
                     valMax=float((upper_bound)*ras[reaction])
@@ -127,23 +128,24 @@
                     if upper_bound!=0 and lower_bound!=0:
                         model_new.reactions.get_by_id(reaction).lower_bound=valMin
                         model_new.reactions.get_by_id(reaction).upper_bound=valMax
-        else:
-            for reaction in rxns_ids:
-                lower_bound=model_new.reactions.get_by_id(reaction).lower_bound
-                upper_bound=model_new.reactions.get_by_id(reaction).upper_bound
-                valMax = float((upper_bound)*1)
-                valMin=float((lower_bound)*1)
-                if upper_bound!=0 and lower_bound==0:
-                    model_new.reactions.get_by_id(reaction).upper_bound=valMax
-                if upper_bound==0 and lower_bound!=0:
-                    model_new.reactions.get_by_id(reaction).lower_bound=valMin
-                if upper_bound!=0 and lower_bound!=0:
-                    model_new.reactions.get_by_id(reaction).lower_bound=valMin
-                    model_new.reactions.get_by_id(reaction).upper_bound=valMax
-        bounds = pd.DataFrame(columns = ["lower_bound", "upper_bound"], index=rxns_ids)
-        for reaction in model.reactions:
-            bounds.loc[reaction.id] = [reaction.lower_bound, reaction.upper_bound]
-        bounds.to_csv(ARGS.output_folder + cellName, sep = '\t', index = False)
+    else:
+        for reaction in rxns_ids:
+            lower_bound=model_new.reactions.get_by_id(reaction).lower_bound
+            upper_bound=model_new.reactions.get_by_id(reaction).upper_bound
+            valMax = float((upper_bound)*1)
+            valMin=float((lower_bound)*1)
+            if upper_bound!=0 and lower_bound==0:
+                model_new.reactions.get_by_id(reaction).upper_bound=valMax
+            if upper_bound==0 and lower_bound!=0:
+                model_new.reactions.get_by_id(reaction).lower_bound=valMin
+            if upper_bound!=0 and lower_bound!=0:
+                model_new.reactions.get_by_id(reaction).lower_bound=valMin
+                model_new.reactions.get_by_id(reaction).upper_bound=valMax
+
+    bounds = pd.DataFrame(columns = ["lower_bound", "upper_bound"], index=rxns_ids)
+    for reaction in model.reactions:
+        bounds.loc[reaction.id] = [reaction.lower_bound, reaction.upper_bound]
+    bounds.to_csv(ARGS.output_folder + cellName, sep = '\t', index = False)
     pass