Create test.py
Browse files
test.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets.process_mols import (
|
| 2 |
+
generate_conformer,
|
| 3 |
+
read_molecule,
|
| 4 |
+
)
|
| 5 |
+
from rdkit.Chem import AddHs
|
| 6 |
+
import os
|
| 7 |
+
from p_tqdm import p_map
|
| 8 |
+
|
| 9 |
+
# Get list of ligand file paths
|
| 10 |
+
ligand_dir = 'screening_data/2rgp/screening_ligand'
|
| 11 |
+
ligand_files = [os.path.join(ligand_dir, f) for f in os.listdir(ligand_dir)]
|
| 12 |
+
|
| 13 |
+
def process_ligand(ligand_description):
|
| 14 |
+
"""Processes a ligand: reads, removes conformers, adds hydrogens, and generates conformers."""
|
| 15 |
+
mol = read_molecule(ligand_description, remove_hs=False, sanitize=True)
|
| 16 |
+
mol.RemoveAllConformers()
|
| 17 |
+
mol = AddHs(mol)
|
| 18 |
+
status = generate_conformer(mol)
|
| 19 |
+
return ligand_description if not status else None
|
| 20 |
+
|
| 21 |
+
# Run in parallel
|
| 22 |
+
failed_ligands = list(filter(None, p_map(process_ligand, ligand_files)))
|
| 23 |
+
|
| 24 |
+
print(f"Failed ligands: {failed_ligands}")
|