hemantn commited on
Commit
d6bccfb
·
1 Parent(s): bf5aaae

Fix: Properly handle errors from prepare_structure in API endpoint

Browse files

- API now checks if prepare_structure returns an error and returns 400 status
- Previously, errors were silently wrapped as success with 0 atoms
- This fixes the '0 atoms proceeded' bug when ligand processing fails

Files changed (1) hide show
  1. amberprep/app.py +5 -0
amberprep/app.py CHANGED
@@ -2100,6 +2100,11 @@ def prepare_structure_endpoint():
2100
  # Prepare structure (use OUTPUT_DIR so paths match app's output folder)
2101
  result = prepare_structure(pdb_content, options, output_dir=str(OUTPUT_DIR))
2102
 
 
 
 
 
 
2103
  # Validate and sanitize ligand names early (after structure preparation)
2104
  # This ensures numeric ligand names are converted to 3-letter codes
2105
  ligand_name_changes = validate_and_sanitize_all_ligand_files()
 
2100
  # Prepare structure (use OUTPUT_DIR so paths match app's output folder)
2101
  result = prepare_structure(pdb_content, options, output_dir=str(OUTPUT_DIR))
2102
 
2103
+ # Check if prepare_structure returned an error
2104
+ if result.get('error'):
2105
+ logger.error(f"Structure preparation failed: {result['error']}")
2106
+ return jsonify({'error': result['error']}), 400
2107
+
2108
  # Validate and sanitize ligand names early (after structure preparation)
2109
  # This ensures numeric ligand names are converted to 3-letter codes
2110
  ligand_name_changes = validate_and_sanitize_all_ligand_files()