Fix: Create combined ligand file (4_ligands_corrected.pdb) for separate ligand download
Browse files- The 'Create separate file for ligand' feature was failing because
4_ligands_corrected.pdb was never created (only individual files were)
- Now combines all corrected ligand files into a single downloadable file
amberprep/structure_preparation.py
CHANGED
|
@@ -879,6 +879,16 @@ def prepare_structure(pdb_content, options, output_dir="output"):
|
|
| 879 |
if lig_lines: # Only add non-empty ligand groups
|
| 880 |
all_ligand_groups.append(lig_lines)
|
| 881 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 882 |
# Merge protein and all ligands (with TER records between ligands)
|
| 883 |
if not merge_protein_and_ligand(protein_capped_file, None, tleap_ready_file, ligand_groups=all_ligand_groups):
|
| 884 |
raise Exception("Failed to merge protein and ligands")
|
|
|
|
| 879 |
if lig_lines: # Only add non-empty ligand groups
|
| 880 |
all_ligand_groups.append(lig_lines)
|
| 881 |
|
| 882 |
+
# Create combined ligand file (4_ligands_corrected.pdb) for separate download
|
| 883 |
+
with open(ligand_corrected_file, 'w') as f:
|
| 884 |
+
for i, lig_group in enumerate(all_ligand_groups):
|
| 885 |
+
for line in lig_group:
|
| 886 |
+
f.write(line if line.endswith('\n') else line + '\n')
|
| 887 |
+
if i < len(all_ligand_groups) - 1:
|
| 888 |
+
f.write('TER\n')
|
| 889 |
+
f.write('END\n')
|
| 890 |
+
print(f"Created combined ligand file: {ligand_corrected_file}")
|
| 891 |
+
|
| 892 |
# Merge protein and all ligands (with TER records between ligands)
|
| 893 |
if not merge_protein_and_ligand(protein_capped_file, None, tleap_ready_file, ligand_groups=all_ligand_groups):
|
| 894 |
raise Exception("Failed to merge protein and ligands")
|