Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use residue template matching to prepare ligands in PDB format #317

Open
diogomart opened this issue Feb 13, 2025 · 2 comments
Open

Use residue template matching to prepare ligands in PDB format #317

diogomart opened this issue Feb 13, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@diogomart
Copy link
Contributor

Kudos to @rwxayheee for this idea. Would enable:

mk_prepare_ligand.py -i ligand.pdb

as long as the residue name can be looked up in the CCD

@diogomart diogomart added the enhancement New feature or request label Feb 13, 2025
@rwxayheee
Copy link
Contributor

rwxayheee commented Feb 17, 2025

Hi @diogomart

I can work on this some time later. Just a few thoughts:

It's easy to do with Python scripting (see example at the end), but adding it to mk_prepare_ligand.py requires a PDB parser or Polymer constructor, and ResidueChemTemplates. Currently, the CLI script is designed more for batch processing of ligands from SDF, not so optimal for covalent ligands or ligands from PDB. Part of it can be re-used, while there are other things that are different from the standard ligand preparation.

It needs a little more work and the addition could make the CLI script even longer. I would also like to add options to modify/override a template from CCD.

Here's a Python example for people interested in trying. No input is required. Prody fetches the PDB file with the given PDB ID, and the ligand is specified by residue name.

#!/usr/bin/env python

""""
micromamba create -c conda-forge -n meeko_tutorial_py39 python=3.9 -y
micromamba activate meeko_tutorial_py39

micromamba install -c conda-forge numpy scipy rdkit gemmi meeko -y

pip install prody
"""

from rdkit import Chem

import prody

from meeko import MoleculePreparation
mk_prep = MoleculePreparation()
from meeko import PDBQTWriterLegacy
from meeko import Polymer
from meeko import ResidueChemTemplates

# PDB ID or PDB filename of the starting ligand structure
pdb_token = "4kqy"

# ProDy selection language to define ligand atoms
lig_atoms_selection = "resname SAM"

pdb_prody_mol = prody.parsePDB(pdb_token)
lig_prody_mol = pdb_prody_mol.select(lig_atoms_selection)

templates = ResidueChemTemplates.create_from_defaults()
polymer = Polymer.from_prody(
    lig_prody_mol,
    templates,
    mk_prep,
    default_altloc="A",
)

output_bname = "lig_"

for lig_resid in polymer.monomers.keys(): 
    resid = lig_resid
    mol = polymer.monomers[lig_resid].rdkit_mol # should have all Hs
    atom_names = polymer.monomers[lig_resid].atom_names
    for i,atom in enumerate(mol.GetAtoms()): 
        pdb_residue_info = Chem.AtomPDBResidueInfo(atomName=atom_names[i])
        atom.SetMonomerInfo(pdb_residue_info)

    molsetup_list = mk_prep(mol)
    molsetup = molsetup_list[0]

    pdbqt_string = PDBQTWriterLegacy.write_string(molsetup)[0]

    output_pdbqt = output_bname + f"{pdb_token}_{resid}.pdbqt".replace(":","-")
    with open(output_pdbqt, 'w') as f:
        f.write(pdbqt_string)
    print(f"File written: {output_pdbqt}")

@diogomart
Copy link
Contributor Author

Either a new script or adding to mk_prepare_ligand.py look good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants