# HG changeset patch # User luca_milaz # Date 1721593350 0 # Node ID a0cc4dd5fea1806985aa1580c6d434f81e14eac9 # Parent 32bef0ad664a19dfc72140bb142d27c3f66bca05 Uploaded diff -r 32bef0ad664a -r a0cc4dd5fea1 marea_2/ras_to_bounds.py --- 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 ##############################################################################