changeset 130:957b9f5006b0 draft

Uploaded
author luca_milaz
date Sun, 21 Jul 2024 20:29:41 +0000
parents a0cc4dd5fea1
children 6ac8a71fdf43
files marea_2/ras_to_bounds.py
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2/ras_to_bounds.py	Sun Jul 21 20:22:30 2024 +0000
+++ b/marea_2/ras_to_bounds.py	Sun Jul 21 20:29:41 2024 +0000
@@ -128,6 +128,10 @@
                     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
@@ -141,11 +145,12 @@
             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 + "bounds", sep = '\t', index = False)
 
-    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
 
 
@@ -159,7 +164,7 @@
     """
     if not os.path.exists('ras_to_bounds'):
         os.makedirs('ras_to_bounds')
-        
+
     if not os.path.exists('ras_to_bounds_medium'):
         os.makedirs('ras_to_bounds_medium')
 
@@ -197,10 +202,8 @@
     else:
         generate_bounds(model, medium)
 
-    with open(mediumPath.show(), mode='w', newline='') as file:
-        writer = csv.DictWriter(file, fieldnames=medium[0].keys(), delimiter='\t')
-        writer.writeheader()
-        writer.writerows(medium)
+    mediumDf = pd.DataFrame.from_dict(medium, orient='index', columns=["value"])
+    mediumDf.to_csv(mediumPath.show(), sep = '\t')
     pass
         
 ##############################################################################