reverse=True)[0]
ligand_amap = hetatm_residues[ligand_key]
ligand = AtomListToSubMol(mol, ligand_amap, includeConformer=True)
ligand_coords = np.array(ligand.GetConformer().GetPositions())
// Get protein and waters
blacklist_ids = list(chain(*hetatm_residues.values()))
protein_amap = np.array([i for i in range(mol.GetNumAtoms())
if i not in blacklist_ids])
protein_coords = np.array(mol.GetConformer().GetPositions())[protein_amap]
// Pocket selection based on cutoff
mask = (cdist(protein_coords, ligand_coords) <= cutoff).any(axis=1)
// IDs of atoms within cutoff
pocket_amap = protein_amap[np.where(mask)[0]].tolist()
// Expand pocket"s residues
if expandResidues:
pocket_residues = OrderedDict()
for res_id in protein_residues.keys():
if any(1 for res_aix in protein_residues[res_id]
if res_aix in pocket_amap):
pocket_residues[res_id] = protein_residues[res_id]
pocket_amap = list(chain(*pocket_residues.values()))
// Create pocket mol, pocket_amap needs to be mapped to mol Idxs
pocket = AtomListToSubMol(mol, pocket_amap, includeConformer=True)
return pocket, ligand
After Change
reverse=True)[0]
ligand_amap = hetatm_residues[ligand_key]
ligand = AtomListToSubMol(mol, ligand_amap, includeConformer=True)
conf = ligand.GetConformer()
ligand_coords = np.array([conf.GetAtomPosition(i)
for i in range(ligand.GetNumAtoms())])
// Get protein and waters
blacklist_ids = list(chain(*hetatm_residues.values()))
protein_amap = np.array([i for i in range(mol.GetNumAtoms())
if i not in blacklist_ids])
conf = mol.GetConformer()
protein_coords = np.array([conf.GetAtomPosition(i)
for i in range(mol.GetNumAtoms())])[protein_amap]
// Pocket selection based on cutoff
mask = (cdist(protein_coords, ligand_coords) <= cutoff).any(axis=1)
// IDs of atoms within cutoff
pocket_amap = protein_amap[np.where(mask)[0]].tolist()
// Expand pocket"s residues
if expandResidues:
pocket_residues = OrderedDict()
for res_id in protein_residues.keys():
if any(1 for res_aix in protein_residues[res_id]
if res_aix in pocket_amap):
pocket_residues[res_id] = protein_residues[res_id]
pocket_amap = list(chain(*pocket_residues.values()))
// Create pocket mol, pocket_amap needs to be mapped to mol Idxs
pocket = AtomListToSubMol(mol, pocket_amap, includeConformer=True)
return pocket, ligand