comparison COBRAxy/custom_data_generator.py @ 363:941ff9b896e4 draft

Uploaded
author francesco_lapi
date Thu, 04 Sep 2025 23:39:51 +0000
parents ca5d82f9075f
children 8a6da55f4e0e
comparison
equal deleted inserted replaced
362:cff85be01ad9 363:941ff9b896e4
36 help="Custom medium file if medium_selector=Custom") 36 help="Custom medium file if medium_selector=Custom")
37 37
38 parser.add_argument("--output_format", type=str, choices=["tabular", "xlsx"], required=True, 38 parser.add_argument("--output_format", type=str, choices=["tabular", "xlsx"], required=True,
39 help="Output format: CSV (tabular) or Excel (xlsx)") 39 help="Output format: CSV (tabular) or Excel (xlsx)")
40 40
41 parser.add_argument('-idop', '--output_path', type = str, default='result', 41 parser.add_argument("--out_data", type=str, required=True,
42 help = 'output path for the result files (default: result)') 42 help="Output file for the merged dataset (CSV or XLSX)")
43
43 44
44 parser.add_argument("--tool_dir", type=str, default=os.path.dirname(__file__), 45 parser.add_argument("--tool_dir", type=str, default=os.path.dirname(__file__),
45 help="Tool directory (passed from Galaxy as $__tool_directory__)") 46 help="Tool directory (passed from Galaxy as $__tool_directory__)")
46 47
47
48 48
49 return parser.parse_args(args) 49 return parser.parse_args(args)
50 50
51 ################################- INPUT DATA LOADING -################################ 51 ################################- INPUT DATA LOADING -################################
52 def load_custom_model(file_path :utils.FilePath, ext :Optional[utils.FileFormat] = None) -> cobra.Model: 52 def load_custom_model(file_path :utils.FilePath, ext :Optional[utils.FileFormat] = None) -> cobra.Model:
253 253
254 #merged.to_csv(out_file, sep = '\t', index = False) 254 #merged.to_csv(out_file, sep = '\t', index = False)
255 255
256 256
257 #### 257 ####
258 out_data_path = ARGS.output_path # Galaxy provides a filepath 258 out_data_path = ARGS.out_data # Galaxy provides a filepath
259 259
260 if ARGS.output_format == "xlsx": 260 if ARGS.output_format == "xlsx":
261 merged.to_excel(out_data_path, index=False) 261 merged.to_excel(out_data_path, index=False)
262 else: 262 else:
263 merged.to_csv(out_data_path, sep="\t", index=False) 263 merged.to_csv(out_data_path, sep="\t", index=False)
264 264
265 print(f"Custom data generated for model '{model_name}' and saved to '{out_data_path}'")
266 265
267 266
268 if __name__ == '__main__': 267 if __name__ == '__main__':
269 main() 268 main()