moavs / test.py
tai-dang11's picture
Create test.py
a7c62bf verified
raw
history blame contribute delete
801 Bytes
from datasets.process_mols import (
generate_conformer,
read_molecule,
)
from rdkit.Chem import AddHs
import os
from p_tqdm import p_map
# Get list of ligand file paths
ligand_dir = 'screening_data/2rgp/screening_ligand'
ligand_files = [os.path.join(ligand_dir, f) for f in os.listdir(ligand_dir)]
def process_ligand(ligand_description):
"""Processes a ligand: reads, removes conformers, adds hydrogens, and generates conformers."""
mol = read_molecule(ligand_description, remove_hs=False, sanitize=True)
mol.RemoveAllConformers()
mol = AddHs(mol)
status = generate_conformer(mol)
return ligand_description if not status else None
# Run in parallel
failed_ligands = list(filter(None, p_map(process_ligand, ligand_files)))
print(f"Failed ligands: {failed_ligands}")