# HG changeset patch # User francesco_lapi # Date 1759248788 0 # Node ID df90f40a156cc860aa9f542b22cf05e38d86afa9 # Parent 36838126cc0725f66f8ef104ef31357395544143 Uploaded diff -r 36838126cc07 -r df90f40a156c COBRAxy/flux_to_map.py --- a/COBRAxy/flux_to_map.py Tue Sep 30 15:32:27 2025 +0000 +++ b/COBRAxy/flux_to_map.py Tue Sep 30 16:13:08 2025 +0000 @@ -400,7 +400,7 @@ continue if isinstance(foldChange, str): foldChange = float(foldChange) - if pValue >= ARGS.pValue: # pValue above tresh: dashed arrow + if pValue > ARGS.pValue: # pValue above tresh: dashed arrow INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId) INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId, mindReactionDir = False) diff -r 36838126cc07 -r df90f40a156c COBRAxy/marea.py --- a/COBRAxy/marea.py Tue Sep 30 15:32:27 2025 +0000 +++ b/COBRAxy/marea.py Tue Sep 30 16:13:08 2025 +0000 @@ -491,7 +491,7 @@ if math.isnan(pValue) or (isinstance(foldChange, float) and math.isnan(foldChange)): continue if isinstance(foldChange, str): foldChange = float(foldChange) - if pValue >= ARGS.pValue: # pValue above tresh: dashed arrow + if pValue > ARGS.pValue: # pValue above tresh: dashed arrow INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId) continue diff -r 36838126cc07 -r df90f40a156c COBRAxy/metabolicModel2Tabular.py --- a/COBRAxy/metabolicModel2Tabular.py Tue Sep 30 15:32:27 2025 +0000 +++ b/COBRAxy/metabolicModel2Tabular.py Tue Sep 30 16:13:08 2025 +0000 @@ -36,7 +36,7 @@ parser.add_argument("--model", type=str, help="Built-in model identifier (e.g., ENGRO2, Recon, HMRcore)") parser.add_argument("--input", type=str, - help="Custom model file (JSON or XML)") + help="Custom model file (JSON, XML, MAT, YAML)") parser.add_argument("--name", nargs='*', required=True, help="Model name (default or custom)") @@ -56,6 +56,43 @@ return parser.parse_args(args) ################################- INPUT DATA LOADING -################################ +def detect_file_format(file_path: str) -> utils.FileFormat: + """ + Detect file format by examining file content and extension. + Handles Galaxy .dat files by looking at content. + """ + try: + with open(file_path, 'r') as f: + first_lines = ''.join([f.readline() for _ in range(5)]) + + # Check for XML (SBML) + if ' cobra.Model: """ Loads a custom model from a file, either in JSON, XML, MAT, or YML format. @@ -186,9 +223,9 @@ ARGS.name = ' '.join(ARGS.name) if ARGS.input: - # Load a custom model from file - model = load_custom_model( - utils.FilePath.fromStrPath(ARGS.input), utils.FilePath.fromStrPath(ARGS.input).ext) + # Load a custom model from file with auto-detected format + detected_format = detect_file_format(ARGS.input) + model = load_custom_model(utils.FilePath.fromStrPath(ARGS.input), detected_format) else: # Load a built-in model if not ARGS.model: diff -r 36838126cc07 -r df90f40a156c COBRAxy/metabolicModel2Tabular.xml --- a/COBRAxy/metabolicModel2Tabular.xml Tue Sep 30 15:32:27 2025 +0000 +++ b/COBRAxy/metabolicModel2Tabular.xml Tue Sep 30 16:13:08 2025 +0000 @@ -70,7 +70,7 @@ - + diff -r 36838126cc07 -r df90f40a156c COBRAxy/tabular2MetabolicModel.py --- a/COBRAxy/tabular2MetabolicModel.py Tue Sep 30 15:32:27 2025 +0000 +++ b/COBRAxy/tabular2MetabolicModel.py Tue Sep 30 16:13:08 2025 +0000 @@ -41,7 +41,6 @@ parser.add_argument("--output", type=str, required=True, help="Output model file path") - parser.add_argument("--tool_dir", type=str, default=os.path.dirname(__file__), help="Tool directory (passed from Galaxy as $__tool_directory__)") @@ -86,8 +85,11 @@ logging.exception('Cannot create output directory: %s', out_dir) model = modelUtils.build_cobra_model_from_csv(ARGS.input) + + + logging.info('Created model with name: %s (ID: %s)', model.name, model.id) - # Save model in requested format + # Save model in requested format - Galaxy handles the filename if ARGS.format == "sbml": cobra.io.write_sbml_model(model, ARGS.output) elif ARGS.format == "json": @@ -98,14 +100,17 @@ cobra.io.save_yaml_model(model, ARGS.output) else: logging.error('Unknown format requested: %s', ARGS.format) - print(f"ERROR: Unknown format: {ARGS.format}") + raise ValueError(f"Unknown format: {ARGS.format}") logging.info('Model successfully written to %s (format=%s)', ARGS.output, ARGS.format) + print(f"Model created successfully in {ARGS.format.upper()} format") - except Exception: + except Exception as e: # Log full traceback to the out_log so Galaxy users/admins can see what happened logging.exception('Unhandled exception in fromCSVtoCOBRA') + print(f"ERROR: {str(e)}") + raise if __name__ == '__main__': diff -r 36838126cc07 -r df90f40a156c COBRAxy/tabular2MetabolicModel.xml --- a/COBRAxy/tabular2MetabolicModel.xml Tue Sep 30 15:32:27 2025 +0000 +++ b/COBRAxy/tabular2MetabolicModel.xml Tue Sep 30 16:13:08 2025 +0000 @@ -19,7 +19,7 @@ python $__tool_directory__/tabular2MetabolicModel.py --tool_dir $__tool_directory__ --input $input - --format $format + --format $format --output $output --out_log $log ]]> @@ -27,6 +27,7 @@ + @@ -37,8 +38,8 @@ - - + +