LBC-LNBio / pyKVFinder

pyKVFinder: Python-C parallel KVFinder
https://lbc-lnbio.github.io/pyKVFinder/
GNU General Public License v3.0
19 stars 10 forks source link

Question: Performing a Localized Search #42

Closed egurapha closed 1 year ago

egurapha commented 1 year ago

Hello! I've found pyKVFinder to be an excellent tool for my work. Thanks for continuing to maintain it. Is it possible to run it on only a subset of residues? Say if I want to detect any pockets formed by say residues 1,23,45,80. I know the process returns the set of residues comprising each pocket, but I was wondering if there was a way to specify this beforehand. Thanks!

jvsguerra commented 1 year ago

Hi @egurapha,

Thank you for your positive feedback on pyKVFinder! In response to your question, yes, it is possible to run pyKVFinder on a subset of residues.

Here are two options:

import os
import pyKVFinder

# Detection parameters
step = 0.6
probe_out = 4.0
pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')

# Read atomic information from PDB file
atomic = pyKVFinder.read_pdb(pdb)

# Get vertices of the 3D grid
vertices = pyKVFinder.get_vertices(atomic, probe_out=probe_out, step=step)

# Run detection
ncav, cavities = pyKVFinder.detect(atomic, vertices, probe_out=probe_out, step=step)

# Run constitutional characterization
residues = pyKVFinder.constitutional(cavities, atomic, vertices, step=step)
print(residues)
{'KAA': [['14', 'E', 'SER'], ['15', 'E', 'VAL'], ['18', 'E', 'PHE'], ['19', 'E', 'LEU'], ['100', 'E', 'PHE'], ['152', 'E', 'LEU'], ['155', 'E', 'GLU'], ['156', 'E', 'TYR'], ['292', 'E', 'LYS'], ['302', 'E', 'TRP'], ['303', 'E', 'ILE'], ['306', 'E', 'TYR']], 'KAB': [['18', 'E', 'PHE'], ['22', 'E', 'ALA'], ['25', 'E', 'ASP'], ['26', 'E', 'PHE'], ['29', 'E', 'LYS'], ['97', 'E', 'ALA'], ['98', 'E', 'VAL'], ['99', 'E', 'ASN'], ['156', 'E', 'TYR']], 'KAC': [['141', 'E', 'PRO'], ['142', 'E', 'HIS'], ['144', 'E', 'ARG'], ['145', 'E', 'PHE'], ['148', 'E', 'ALA'], ['299', 'E', 'THR'], ['300', 'E', 'THR'], ['305', 'E', 'ILE'], ['310', 'E', 'VAL'], ['311', 'E', 'GLU'], ['313', 'E', 'PRO']], 'KAD': [['122', 'E', 'TYR'], ['124', 'E', 'ALA'], ['176', 'E', 'GLN'], ['318', 'E', 'PHE'], ['320', 'E', 'GLY'], ['321', 'E', 'PRO'], ['322', 'E', 'GLY'], ['323', 'E', 'ASP']], 'KAE': [['95', 'E', 'LEU'], ['98', 'E', 'VAL'], ['99', 'E', 'ASN'], ['100', 'E', 'PHE'], ['103', 'E', 'LEU'], ['104', 'E', 'VAL'], ['105', 'E', 'LYS'], ['106', 'E', 'LEU']], 'KAF': [['123', 'E', 'VAL'], ['124', 'E', 'ALA'], ['175', 'E', 'ASP'], ['176', 'E', 'GLN'], ['181', 'E', 'GLN']], 'KAG': [['34', 'E', 'SER'], ['37', 'E', 'THR'], ['96', 'E', 'GLN'], ['106', 'E', 'LEU'], ['107', 'E', 'GLU'], ['108', 'E', 'PHE'], ['109', 'E', 'SER']], 'KAH': [['49', 'E', 'LEU'], ['50', 'E', 'GLY'], ['51', 'E', 'THR'], ['52', 'E', 'GLY'], ['53', 'E', 'SER'], ['54', 'E', 'PHE'], ['55', 'E', 'GLY'], ['56', 'E', 'ARG'], ['57', 'E', 'VAL'], ['70', 'E', 'ALA'], ['72', 'E', 'LYS'], ['74', 'E', 'LEU'], ['84', 'E', 'GLN'], ['87', 'E', 'HIS'], ['88', 'E', 'THR'], ['91', 'E', 'GLU'], ['104', 'E', 'VAL'], ['120', 'E', 'MET'], ['121', 'E', 'GLU'], ['122', 'E', 'TYR'], ['123', 'E', 'VAL'], ['127', 'E', 'GLU'], ['166', 'E', 'ASP'], ['168', 'E', 'LYS'], ['170', 'E', 'GLU'], ['171', 'E', 'ASN'], ['173', 'E', 'LEU'], ['183', 'E', 'THR'], ['184', 'E', 'ASP'], ['186', 'E', 'GLY'], ['187', 'E', 'PHE'], ['201', 'E', 'THR'], ['327', 'E', 'PHE']], 'KAI': [['131', 'E', 'HIS'], ['138', 'E', 'PHE'], ['142', 'E', 'HIS'], ['146', 'E', 'TYR'], ['174', 'E', 'ILE'], ['314', 'E', 'PHE']], 'KAJ': [['33', 'E', 'PRO'], ['89', 'E', 'LEU'], ['92', 'E', 'LYS'], ['93', 'E', 'ARG'], ['96', 'E', 'GLN'], ['349', 'E', 'GLU'], ['350', 'E', 'PHE']], 'KAK': [['157', 'E', 'LEU'], ['162', 'E', 'LEU'], ['163', 'E', 'ILE'], ['164', 'E', 'TYR'], ['185', 'E', 'PHE'], ['188', 'E', 'ALA']], 'KAL': [['49', 'E', 'LEU'], ['127', 'E', 'GLU'], ['129', 'E', 'PHE'], ['130', 'E', 'SER'], ['326', 'E', 'ASN'], ['327', 'E', 'PHE'], ['328', 'E', 'ASP'], ['330', 'E', 'TYR']], 'KAM': [['51', 'E', 'THR'], ['55', 'E', 'GLY'], ['56', 'E', 'ARG'], ['73', 'E', 'ILE'], ['74', 'E', 'LEU'], ['75', 'E', 'ASP'], ['115', 'E', 'ASN'], ['335', 'E', 'ILE'], ['336', 'E', 'ARG']], 'KAN': [['165', 'E', 'ARG'], ['166', 'E', 'ASP'], ['167', 'E', 'LEU'], ['199', 'E', 'CYS'], ['200', 'E', 'GLY'], ['201', 'E', 'THR'], ['204', 'E', 'TYR'], ['205', 'E', 'LEU'], ['206', 'E', 'ALA'], ['209', 'E', 'ILE'], ['219', 'E', 'VAL'], ['220', 'E', 'ASP'], ['223', 'E', 'ALA']], 'KAO': [['48', 'E', 'THR'], ['51', 'E', 'THR'], ['56', 'E', 'ARG'], ['330', 'E', 'TYR'], ['331', 'E', 'GLU']], 'KAP': [['222', 'E', 'TRP'], ['238', 'E', 'PHE'], ['253', 'E', 'GLY'], ['254', 'E', 'LYS'], ['255', 'E', 'VAL'], ['273', 'E', 'LEU']], 'KAQ': [['207', 'E', 'PRO'], ['208', 'E', 'GLU'], ['211', 'E', 'LEU'], ['213', 'E', 'LYS'], ['275', 'E', 'VAL'], ['277', 'E', 'LEU']], 'KAR': [['237', 'E', 'PRO'], ['238', 'E', 'PHE'], ['249', 'E', 'LYS'], ['254', 'E', 'LYS'], ['255', 'E', 'VAL'], ['256', 'E', 'ARG']]}

# Export cavities to PDB file
# NOTE: Assuming you want cavities that have residue 14 of chain E, i.e., KAA
pyKVFinder.export('cavity.pdb', cavities, None, vertices, step=step, selection=['KAA'])
import numpy

# Detection parameters
step = 0.6
probe_out = 4.0
ligand_cutoff=10.0
pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')

# Read atomic information from PDB file
atomic = pyKVFinder.read_pdb(pdb)

# Get vertices of the 3D grid
vertices = pyKVFinder.get_vertices(atomic, probe_out=probe_out, step=step)

# Before detection we need to define a ligand. 
#
# We read the information in two ways, that are:
# 1. Read the ligand from a PDB file
# ligand = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', 'ADN.pdb')
# latomic = pyKVFinder.read_pdb(ligand)
#
# 2. Define the ligand by hand: select the ligand in atomic
mask = numpy.where((atomic[:, 0] == '14') & (atomic[:, 1] == 'E') )
latomic = atomic[mask[0], ]
# Run detection with ligand adjustment
# NOTE: Use a large distance cutoff
# Adjust this cutoff according to the size of the cavity you want to detect.
ncav, cavities = pyKVFinder.detect(atomic, vertices, probe_out=probe_out, step=step, latomic=latomic, ligand_cutoff=ligand_cutoff)

# Export cavity to PDB file
pyKVFinder.export('cavity.pdb', cavities, None, vertices, step=step)

Please note that for Option 2, you may want to consider selecting patches of residues instead of single core residues in the region of interest to ensure the entire cavity is detected.

Here is a tutorial for the ligand adjustment mode: https://lbc-lnbio.github.io/pyKVFinder/_tutorial/index.html#detecting-biomolecular-cavities-with-ligand-adjustment.

I hope this helps! If you have any further questions, please feel free to ask.

egurapha commented 1 year ago

Hi @jvsguerra, thanks very much for the detailed explanation. The pyKVFinder.constitutional function works for me!