changeset 129:a0cc4dd5fea1 draft

Uploaded
author luca_milaz
date Sun, 21 Jul 2024 20:22:30 +0000
parents 32bef0ad664a
children 957b9f5006b0
files marea_2/ras_to_bounds.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2/ras_to_bounds.py	Sun Jul 21 20:17:36 2024 +0000
+++ b/marea_2/ras_to_bounds.py	Sun Jul 21 20:22:30 2024 +0000
@@ -6,6 +6,7 @@
 import pandas as pd
 import cobra
 import sys
+import csv
 
 ################################# process args ###############################
 def process_args(args :List[str]) -> argparse.Namespace:
@@ -116,7 +117,6 @@
         for cellName, ras in ras.iterrows():
             for reaction in rxns_ids:
                 if (reaction in ras.keys() and ras[reaction] != None and pd.notna(ras[reaction])):
-                    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])
@@ -159,13 +159,16 @@
     """
     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')
 
     global ARGS
     ARGS = process_args(sys.argv)
 
     ARGS.output_folder = 'ras_to_bounds/'
 
-    mediumPath = utils.FilePath("medium", ".csv", prefix = ARGS.output_folder)
+    mediumPath = utils.FilePath("medium", ".csv", prefix = 'ras_to_bounds_medium')
 
     if(ARGS.ras_selector == True):
         ras = read_dataset(ARGS.input_ras, "ras dataset")
@@ -194,7 +197,10 @@
     else:
         generate_bounds(model, medium)
 
-    medium.to_csv(mediumPath.show())
+    with open(mediumPath.show(), mode='w', newline='') as file:
+        writer = csv.DictWriter(file, fieldnames=medium[0].keys(), delimiter='\t')
+        writer.writeheader()
+        writer.writerows(medium)
     pass
         
 ##############################################################################